Consider the following C functions.
int fun1 (int n) { | int fun2 (int n) { |
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