GATE CS 2014, set 2 · Question 52 · Programming and Data Structures · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer

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 ?

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

Answer (D)

Answer from the official GATE CS 2014 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes