Question: Considering the following skeletal program: program main; var x : integer; procedure sub 1 ; procedure sub 2 ; . . . end; { sub

Considering the following skeletal program:
program main;
var x : integer;
procedure sub1;
procedure sub2;
...
end; {sub2}
...
end; {sub1}
procedure sub3;
var x : integer;
procedure sub4;
var x : integer;
....
end; {sub4}
...
end; {sub3}
...
end; {main}
Assuming the following execution of the program:
main calls sub3
sub3 calls sub4
sub4 calls sub1
sub1 calls sub2
Assuming static scoping, state which declaration of x (by line #) is used to reference x in sub1, sub2, sub3, sub4, main
Do the same for dynamic scoping as well.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!