ProgrammingModerateAccenture · TCS NQT

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer n = 0, c = 0
do
    c = c + 1
    n = n + 3
while (n mod 5 != 0)
Print c, n
  1. A. 4 12
  2. B. 5 15
  3. C. 6 18
  4. D. 1 3

Correct answer: B. 5 15

The do-while body runs before the test: n goes 3, 6, 9, 12, 15 and stops at the first multiple of 5, after 5 passes. Output 5 15.

More Pseudocode and Code Tracing questions

Exams that ask this topic