Static and Dynamic Scooping Problem
- by Devyn
Hi,
I'm solving following code in Static and Dynamic Scooping.
I got following answer but I need someone to confirm if I'm correct or not since I'm a bit confusing. I really appreciate if anyone can explain in simple way!
Static => (1)8 (2)27
Dynamic => (1)10 (2)27
proc main
var x,y,z;
proc sub1
var x,z
x := 6;
z := 7;
sub2;
x := y*z + x;
print(x); ---- (2)
end;
proc sub2
var x,y
x := 1;
y := x+z+2;
print(y); ---- (1)
end;
begin
x := 1; y:=3; z:=5;
sub1;
end