ProgrammingModerateCapgemini · Infosys pattern

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer a = 3, b
b = a * a
a = b - a
b = b + a
Print a mod b, b mod a
  1. A. 6 3
  2. B. 0 3
  3. C. 3 6
  4. D. 6 0

Correct answer: A. 6 3

b = 9, a = 9 - 3 = 6, b = 9 + 6 = 15. 6 mod 15 = 6, because the smaller number mod the larger is the smaller number itself, and 15 mod 6 = 3.

More Pseudocode and Code Tracing questions

Exams that ask this topic