ProgrammingEasyTCS NQT · Accenture pattern

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer x = 1
while (x < 100)
    x = x * 3
end while
Print x
  1. A. 729
  2. B. 99
  3. C. 81
  4. D. 243

Correct answer: D. 243

x goes 1 → 3 → 9 → 27 → 81 → 243. The test 81 < 100 is still true, so one more multiplication happens before the loop ends.

More Pseudocode and Code Tracing questions

Exams that ask this topic