-
Consider the following program :
Program P2
var n : int :
procedure W (var x:int)
begin
x = x + 1;
print x;
end procedure D
begin
varn:int;
n = 3;
W (n);
End
begin || begin P2
n = 10;
D;
end
If the language has dynamic scopping and parameters are passed by reference, what will be printed by the program?
-
- 10
- 11
- 3
- None of these
- 10
Correct Option: D
n = 10 given but not passed to D. In D, n = 3 &W(n) increments by 1. So n = n + 1 = 4.
Hence (d) is correct option.