Question 1

What is printed by the print statements in the program P1 assuming call by reference parameter passing?

Program P1()
   x = 10;
   y = 3;
   print x;
   print y;
   y = y+4;
   z = x+y+z;
10, 3
31, 3
27, 7
None of the above
Question 1 Explanation: 
Here, variable x of func1 points to address of variable y.
And variable y and z of func1 points to address of variable x.
Therefore, y = y+4 ⇒ y = 10+4 = 14
and z = x+y+z ⇒ z = 14+14+3 = 31
z will be stored back in k.
Hence, x=31 and y will remain as it is (y=3).
Hence, answer is (B).
There is 1 question to complete.

Access quiz wise question and answers by becoming as a solutions adda PRO SUBSCRIBER with Ad-Free content

Register Now

If you have registered and made your payment please contact to get access