Question 9873 – Programming
February 13, 2024Programming
February 13, 2024Programming
|
Question 36
|
Consider the following program
Program P2
var n: int:
procedure W(var x: int)
begin
x=x+1;
print x;
end
procedure D
begin
var n: int;
n=3;
W(n);
End
begin //beginP2
n=10;
D;
end
If the language has dynamic scoping and parameters are passed by reference, what will be printed by the program?
|
10
|
|
|
11
|
|
|
3
|
|
|
None of the above
|
Question 36 Explanation:
n=3
W(n)=W(3)
Procedure W(var x; int)
begin
x = x+1 = 3+1 = 4
Print x → Print x=4
end
W(n)=W(3)
Procedure W(var x; int)
begin
x = x+1 = 3+1 = 4
Print x → Print x=4
end
Correct Answer: D
Question 36 Explanation:
n=3
W(n)=W(3)
Procedure W(var x; int)
begin
x = x+1 = 3+1 = 4
Print x → Print x=4
end
W(n)=W(3)
Procedure W(var x; int)
begin
x = x+1 = 3+1 = 4
Print x → Print x=4
end
