Consider the following program is pseudo-Pascal syntax
program main;
var x: integer;
procedure Q (z: integer);
begin
z := z+x;
writeln(z);
end;
procedure P (y: integer);
var x: integer;
begin
x := y+2;
Q(x);
writeln(x);
end
begin
x := 5;
P(x);
Q(x);
writeln(x);
end
What is the output of the program when
- the parameter passing mechanism is call-by-value and the scope rule is static scoping?
- the parameter passing mechanism is call-by-reference and the scope rule is dynamic scoping?