ProgrammingEasyTCS NQT · Infosys · Accenture

What will be the output of the following pseudocode? (All variables are integers.)

What will be the output of the following pseudocode? (All variables are integers.)
Integer a = 9, b = 2
a = a * b
b = a / b
a = a / b
Print a, b
  1. A. 2 9
  2. B. 9 2
  3. C. 18 2
  4. D. 2 18

Correct answer: A. 2 9

a = 18; b = 18 / 2 = 9; a = 18 / 9 = 2. The three steps swap the values using multiplication and division.

More Pseudocode and Code Tracing questions

Exams that ask this topic