GATE | Gate IT 2007 | Question 33
Consider the program below in a hypothetical language which allows global variable and a choice of call by reference or call by value methods of parameter passing.
Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.
Which one of the following options represents the correct output of the program for the two parameter passing mechanisms?
(A) Call by value : i = 70, j = 10; Call by reference : i = 60, j = 70
(B) Call by value : i = 50, j = 60; Call by reference : i = 50, j = 70
(C) Call by value : i = 10, j = 70; Call by reference : i = 100, j = 60
(D) Call by value : i = 100, j = 60; Call by reference : i = 10, j = 70
Explanation: Call by value: A copy of parameters will be passed and whatever updations are performed will be valid only for that copy, leaving original values intact.
Call by reference: A link to original variables will be passed, by allowing the function to manipulate the original variables.
Quiz of this Question