Static and Dynamic Scooping Problem

Posted by Devyn on Stack Overflow See other posts from Stack Overflow or by Devyn
Published on 2011-01-03T16:51:17Z Indexed on 2011/01/03 16:53 UTC
Read the original article Hit count: 226

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

© Stack Overflow or respective owner

Related posts about programming-languages

Related posts about pascal