GATE Computer ScienceModerateGATE CSE · IBPS SO

Evaluate the postfix expression 8 2 3 ^ / 2 3 * + 5 3 - - where ^ is exponentiation (x ^ y = xʸ), / is integer division and the operators act on the two topmost stack values. What is the result?

  1. A. 5
  2. B. 6
  3. C. 3
  4. D. 8

Correct answer: A. 5

Stack: 8 2 3 ^ → 8 8; / → 1; 2 3 * → 1 6; + → 7; 5 3 − → 7 2; − → 5.

More Programming and Data Structures (GATE) questions

Exams that ask this topic