Question 132

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));
  1. A8
  2. B5
  3. C4
  4. D3
Show answerHide answer

Correct answer: (C) 4

Explanation

8 → 4 → 2 → 1 → 0 gives 4 calls adding 1.

From DSSSB TGT Computer Science Full Mock Test 5

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.