Assume that the program 'P' is implementing parameter passing with 'call by reference'. What will be printed by following print statements in P?
Assume that the program 'P' is implementing parameter passing with 'call by reference'. What will be printed by following print statements in P?
Program P( )
{
x = 10;
y = 3;
funb (y, x, x); print x; print y;
}
funb (x, y, z)
{
y = y + 4;
z = x + y + z;
}
Show answerHide answer
Correct answer: (B) 31, 3
Explanation
Inside funb( ), x refers to y of main, and both y and z refer to x of main. y = y + 4 makes main's x = 14. z = x + y + z = 3 + 14 + 14 = 31, which is stored in main's x. main's y is unchanged (3). Printed output is 31, 3.