GATE | GATE-CS-2004 | Question 31

Consider the following C function:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


The value returned by f(1) is

(A) 5
(B) 6
(C) 7
(D) 8


Answer: (C)

Explanation: See Question 3 of https://www.geeksforgeeks.org/c-language-set-2/

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.