What is the output of the following postfix expression? 5, 6, 2, +, *, 8, 4,…

2023

What is the output of the following postfix expression?

5, 6, 2, +, *, 8, 4, /, –

  1. A.

    39

  2. B.

    36

  3. C.

    38

  4. D.

    37

Attempted by 161 students.

Show answer & explanation

Correct answer: C

Evaluate the postfix expression using a stack.

6 and 2 are added to get 8; then 5 x 8 = 40.

8 and 4 are divided to get 2; finally 40 - 2 = 38.

Explore the full course: Niacl Ao It Specialist