ProgrammingModerateTCS Digital · Infosys InfyTQ

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer n = 100, c = 0
while (n > 0)
    n = n / 2
    c = c + 1
end while
Print c
  1. A. 6
  2. B. 7
  3. C. 8
  4. D. 5

Correct answer: B. 7

n goes 100, 50, 25, 12, 6, 3, 1, 0 (integer division): 7 iterations.

More Pseudocode and Code Tracing questions

Exams that ask this topic