ProgrammingEasyTCS NQT · Infosys · Accenture

What will be the output of the following pseudocode?

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

Correct answer: D. 4

Integer division removes one digit per pass: 4096, 409, 40, 4, 0 - four passes.

More Pseudocode and Code Tracing questions

Exams that ask this topic