procedure main
a : integer := 1
b : integer := 2
procedure middle
b : integer := a
procedure inner
print a, b
a : integer := 3
-- body of middle
inner()
print a, b
-- body of main
middle()
print a,b
Need to tell what a and b print for each function using the following 3 declaration order rules
C (names must be declared before use, and the scope of a name extends from its declaration through the end of the block)
I think this one is a error, because a is not declared in middle()
C# (names must be declared before use, but the scope of a name is the entire block in which it is declared)
Im guessing this one will run because it uses the entire block? so,
main: 3 - 1
middle: 3 - 1
inner: a - 1 b - 1
Im not sure if this is right or not...I dont really know if the variables are global...if they werent global then it would be a error so I guess they are?
Lastly, Modula-3 ( names can be declared in any order and their scope is the entire block in which they are declared)
Im not really sure..