Consider the following program in pseudo-Pascal syntax. program main; var x:…
PYQ GATE 2000
Consider the following program in 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 (a) the parameter passing mechanism is call-by-value and the scope rule is static scoping? (b) The parameter passing mechanism is call-by-reference and the scope rule is dynamic scoping?
Sign up free to check your answer
Sign up freeLoading lesson…

