What is the output? int f(int n) {
What is the output?
int f(int n) {
return n == 0 ? 0 : n + f(n - 1);
}
printf("%d", f(4));
Show answerHide answer
Correct answer: (B) 10
Explanation
4 + 3 + 2 + 1 + 0 = 10.
Correct answer: (B) 10
Explanation
4 + 3 + 2 + 1 + 0 = 10.
This is question 132 of DSSSB TGT Computer Science Full Mock Test 4. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.