ProgrammingEasyTCS NQT · Wipro pattern

What will be the output of the following pseudocode? (/ is integer division.)

What will be the output of the following pseudocode? (/ is integer division.)
Integer a = 7, b = 3
a = a * b - a / b
Print a
  1. A. 19
  2. B. 18.67
  3. C. 21
  4. D. 14

Correct answer: A. 19

* and / bind tighter than − and are applied left to right: a * b = 21 and a / b = 2 (integer division drops the fraction). 21 − 2 = 19. 18.67 uses real division, which integer variables cannot hold.

More Pseudocode and Code Tracing questions

Exams that ask this topic