ProgrammingEasyTCS NQT · Accenture pattern

What will be the output of the following pseudocode? (All variables are integers, so / is integer division.)

What will be the output of the following pseudocode? (All variables are integers, so / is integer division.)
Integer x, y
Set x = 17, y = 5
Print x / y, x mod y
  1. A. 3 2
  2. B. 3.4 2
  3. C. 2 3
  4. D. 3 3

Correct answer: A. 3 2

With integer division, 17 / 5 = 3 (the fraction is dropped) and 17 mod 5 = 17 - 15 = 2.

More Pseudocode and Code Tracing questions

Exams that ask this topic