Gate CS-2009 Question Paper With Solutions

Q. 46 Consider the program below:

#include <stdio.h> 
 int fun(int n, int *f_p)  {     
 int t, f;    
  if (n <= 1)     
 {          
*f_p = 1;       
   return 1;     
 }     
 t = fun(n- 1,f_p);   
   f = t+ * f_p;      
*f_p = t;   
   return f;  }   
 int main()  {      int x = 15;      
printf (" %d \n",
 fun(5, &x));      return 0;  } 

The value printed is:

(A) 6

(B) 8

(C) 14

(D) 15

Answer: (B)

Explanation:

Gate CS-2009 Question Paper With Solutions

Learn More:   Gate EC-2006 Question Paper With Solutions

LEAVE A REPLY

Please enter your comment!
Please enter your name here