Question: Consider the following program: In each case YOU MUST SHOW ALL OF YOUR WORK proc main { proc A: { proc B; { int x

Consider the following program: In each case YOU MUST SHOW ALL OF YOUR WORK proc main { proc A: { proc B; { int x, a; x :=2; a:=8; call C; print x; }(end B) proc C; { int z; x :=4; z :=7; print a; }(end C) int a; x :=3; z :=5; a:=6; call B; print x; }(end A) proc D; { proc E; { int x, z; x :=5; z:=11; call F; print x; }(end E) proc F; { proc G; { print z; x:=8; call A; print x; }(end G) print x; call G; x:=7; }(end F) int x, b; x :=12; call E; print x; }(end D) int x, z; x:=1; z :=9; call D; print x; }(end main)(a)(6pts) What is the program output assuming static scoping rules are employed? (b)(6pts) What is the corresponding output when dynamic scoping rules are employed? (c)(5pts) List all of the units (proc's) that proc C can call (assuming static scoping).(d)(4pts) Specify the referencing environment of proc F (assuming static scoping) That is, list the variables that are visible to proc F (e)(4pts) Specify the referencing environment of proc F (assuming dynamic scoping) That is, list the variables that are visible to proc F Consider the following program:
In each case YOU MUST SHOW ALL OF YOUR WORK
```
proc main
{
proc A:
{
proc B;
{int x, a;
x:=2
a:=8;
call C;
print x;
}(end B)
proc C;
{ int z;
x:=4;
z:=7;
print a;
)(end C)
int a;
x:=3;
z:=5;
a:=6;
call B;
print x;
}(end A)
proc D;
{
proc E;
{ int x, z;
x:=5;
z:=11;
call F;
print x;
```
```
}(end E)
proc F;
{
proc G;
{ print z;
x:=8;
call A;
print x;
}(end G)
print x;
call G;
x:=7;
}(end F)
int x, b;
x:=12;
call E;
print x;
}(end D)
int x, z;
x:=1;
z :=9;
call D;
print x;
}(end main)
```
(a)(6pts) What is the program output assuming static scoping rules are employed?
(b)(6pts) What is the corresponding output when dynamic scoping rules are employed?
(c)(5pts) List all of the units (proc's) that proc C can call (assuming static scoping).
(d)(4pts) Specify the referencing environment of proc F (assuming static scoping) That is, list the variables that are visible to proc F
(e)(4pts) Specify the referencing environment of proc F (assuming dynamic scoping) That is, list the variables that are visible to proc F
Consider the following program: In each case YOU

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!