GATE Computer ScienceEasyGATE CS (PYQ pattern)

Evaluate the postfix expression 9 3 - 4 2 * 5 - 7 3 / * + where / is integer division truncating toward zero.

  1. A. 15
  2. B. 10
  3. C. 18
  4. D. 12

Correct answer: D. 12

9 3 - = 6; 4 2 * = 8, 8 5 - = 3; 7 3 / = 2; 3 * 2 = 6; finally 6 + 6 = 12. A careless pop order (y before x) on - or / changes this.

More Programming and Data Structures (GATE) questions

Exams that ask this topic