Sunday, June 3, 2007

Question 45

Consider the following procedure “add.” Its formal argument X is “call by value,” while the formal argument Y is “call by reference.” After the main program has been executed, what are the values of the variables X and Y in the main program?

Main program
Procedure "add" (X, Y)
X :=2;
Y
:=2;
add (X ,Y );
X :=X +Y ;
Y
:=X +Y ;
return;

-


X Y
a 2 2
b 2 6
c 4 2
d 4 6

answer

No comments: