Consider the following C function: int f(int n) { static int i = 1; if(n >= 5)…

ISRO Scientist/Engineer SC · 2008 · Computer ScienceGATE · 2004 · CSTPSC Computer/IT Posts · 2024 · Senior Computer Assistant 2024 · from our data (question pool)

Consider the following C function:

int f(int n)
{
static int i = 1;
if(n >= 5) return n;
n = n+i;
i++;
return f(n);
}

The value returned by f(1) is

  1. A.

    5

  2. B.

    6

  3. C.

    7

  4. D.

    8

Attempted by 662 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…