LogiQuest
Back to Functions
10

What will be the output of the program?

#include <stdio.h>
int sum(int n) { return n == 0 ? 0 : n + sum(n - 1); }
int main(void) {
    printf("%d\n", sum(5));
    return 0;
}
Easy

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.