ProgrammingHardTCS NQT · Infosys · Accenture

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer c = 0
for (i = 100; i > 1; i = i / 3)
    c = c + 1
end for
Print c
  1. A. 3
  2. B. 4
  3. C. 5
  4. D. 33

Correct answer: B. 4

i takes 100, 33, 11, 3 (all > 1) and then 1, which stops the loop: four iterations.

More Pseudocode and Code Tracing questions

Exams that ask this topic