Question: Programming Languages Please Solve: Consider the following pseudocode: procedure main() a : integer := 1 b : integer := 2 c : integer := 3
Programming Languages Please Solve:
Consider the following pseudocode:
procedure main()
a : integer := 1
b : integer := 2
c : integer := 3
procedure first()
b : integer := a
a : integer := 3
procedure second()
print a, b, c
c : integer := b
--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# (names must be declared before use, but the scope of a name is the entire block in which it is declared).
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 a language where names can be declared in any order, and their scope is the entire block in which they are declared.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
