Consider the following C functions.

int fun1 (int n) {
 static int i = 0;
 if (n > 0) {
     ++i;
     fun1 (n-1);
  }
     return (i);
}
int fun2 (int n) {
 static int i = 0;
 if (n > 0) {
    i = i + fun1 (n);
    fun2 (n-1);
  }
  return (i);
}

The return value of fun2(5) is _____.

Correct Answer:

55

Solution:

Step 1:

Step 2: At Line no. 4, fun2(n-1) = fun2(4)

Step 3: At Line no. 4, fun2(n-1) = fun2(3)

Step 4: At Line no. 4, fun2(n-1) = fun2(2)

Step 5: At Line no. 4, fun2(n-1) = fun2(1)

Step 6: At Line no 4, fun2(n1) = fun2(0)   (condition false)
             At Line no 5, return i = 55

output = 55