What is the output? int fun(int n) {
What is the output?
int fun(int n) {
if (n <= 0) return 0;
return fun(n / 2) + 1;
}
printf("%d", fun(8));
Show answerHide answer
Correct answer: (C) 4
Explanation
8 → 4 → 2 → 1 → 0 gives 4 calls adding 1.
Correct answer: (C) 4
Explanation
8 → 4 → 2 → 1 → 0 gives 4 calls adding 1.
This is question 132 of DSSSB TGT Computer Science Full Mock Test 5. 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.