| Chapter 10
1. Show the stack with all activation record instances, including static
and dynamic chains, when execution reaches position 1 in the following
skeletal program.
procedure MAIN
var x: integer;
var z: integer;
procedure fun1
(x: integer);
procedure
fun2 (x: integer);
var y: integer
begin
y := z + x;
fun1(y);
end;
begin
print(x); <------------ 1
end;
procedure fun3(x:
integer)
var
y: integer;
var
z: integer;
begin
z:=1;
y:= x + 2;
fun2(y);
end;
begin
x:= 5;
z:= 3;
fun3(x);
end;
2. Show the stack with all activation record instances, incliding static
and dynamic
chains, when execution reaches position 1 in the following skeletal
program.
int x=8, y=4, z=1;
void main()
{
int z=5;
fun1(z);
}
void fun1(int m)
{
int z=2;
y = y + m;
fun2(y);
}
void fun2(int n)
{
z = z - n;
cout<<z<<endl;
<------------ 1
}
|