Question:medium

Consider the following C function:
int fun(int n){
if (n == 0) return 0;
else return n + fun(n - 1);
}
What does the function fun(4) return?

Show Hint

Always identify the Base Case first. If $n=0$ was not handled, this function would lead to an infinite recursion and eventually a "Stack Overflow" error.
Updated On: Jul 4, 2026
  • 4
  • 10
  • 24
  • 16
Show Solution

The Correct Option is B

Solution and Explanation

Was this answer helpful?
0