Related Articles

# GATE | GATE-CS-2014-(Set-2) | Question 52

• Last Updated : 28 Jun, 2021

Consider the C function given below.

 `int` `f(``int` `j)``{``  ``static` `int` `i = 50;``  ``int` `k;``  ``if` `(i == j)``  ``{``    ``printf``(“something”);``    ``k = f(i);``    ``return` `0;``  ``}``  ``else` `return` `0;``}`

Which one of the following is TRUE?

(A) The function returns 0 for all values of j.
(B) The function prints the string something for all values of j.
(C) The function returns 0 when j = 50.
(D) The function will exhaust the runtime stack or run into an infinite loop when j = 50

Explanation: When j is 50, the function would call itself again and again as neither i nor j is changed inside the recursion.

Quiz of this Question

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.

My Personal Notes arrow_drop_up