Question: Consider the following pseudocode: procedure main() a : integer := 3 b : integer := 5 c : integer := 7 procedure first() b :
Consider the following pseudocode:
procedure main()
a : integer := 3
b : integer := 5
c : integer := 7
procedure first()
b : integer := c
c : integer := b
procedure second()
print a, b, c
a : integer := 2
--body of first
second()
print a, b, c
--body of main
first()
print a, b, c
Suppose this was code for a language with the declaration-order rules of C
(but with nested subroutines)that is, names must be declared before use,
and the scope of a name extends from its declaration through the end of
the block. At each print statement, indicate which declarations of a, b
and c are in the referencing environment. What does the program print (or will
the compiler identify static semantic errors)?
Repeat the exercise for the declaration-order rules of C# (names must be declared before use, but the scope of a name is the entire block in which it is declared).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
