Question: Consider the following pseudocode: procedure main ( ) b : integer : = 1 c : integer : = 2 procedure first ( ) b

Consider the following pseudocode:
procedure main()
b : integer :=1
c : integer :=2
procedure first()
b : integer := c
c : integer := a
procedure second()
print a, b, c
a : integer :=2
--body of first
second()
print a, b, c
--body of main
first()
For each of the following three scenarios, specify
which statements (in which line number) will cause a
static semantic error and why:
a) names must be declared before use, and the scope
of a name extends from its declaration through the
end of the block?
b) names must be declared before use, but the scope
of a name is the entire block in which it is declared?
c) names can be declared in any order, and their
scope is the entire block in which they are declared?
Suppose that procedure swap is declared as follows (using
Pascal syntax):
procedure swap(x, y: integer);
procedure f(a): integer;
begin (* f *)
a := y;
return x
end f;
begin (* swap *)
y := f(x)
end swap;
Describe the effect of the procedure call swap (i,
A [i]) assuming that macro expansion is used.
Consider the following pseudocode: procedure main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!