Consider the following C function: int f(int n) { static int r=0; if (n <= 0)…

GATE · 2007 · CS

Consider the following C function: int f(int n) { static int r=0; if (n <= 0) return 1; if (n > 3) { r = n; return f(n-2)+2; } return f(n-1)+r; } What is the value of f(5)?

  1. A.

    5

  2. B.

    7

  3. C.

    9

  4. D.

    18

Attempted by 304 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…