Question:medium

Give output of the evaluation of the following postfix expression:
10 2 8 * + 3 -

Show Hint

Be very careful when applying subtraction (-) or division (/):
Always calculate the first popped element as the second operand:
\[ \text{Expression} = \text{op1} - \text{op2} \]
Getting the order backwards is a common trap!
Updated On: Jun 11, 2026
  • 23
  • 97
  • 25
  • 47
Show Solution

The Correct Option is A

Solution and Explanation


Step 1: Understanding the Question:

The question asks to evaluate the given postfix mathematical expression and compute its final numerical output using a stack-based evaluation approach.

Step 2: Postfix Evaluation Algorithm:

To evaluate a postfix expression:
- Scan the expression from left to right.
- If an operand (number) is encountered, push it onto the stack.
- If an operator (like +, -, *, /) is encountered:
- Pop the top element as the second operand (op2).
- Pop the next top element as the first operand (op1).
- Perform the operation: result = op1 [operator] op2.
- Push the result back onto the stack.

Step 3: Detailed Step-by-Step Evaluation:

Let us trace the evaluation of: 10 2 8 * + 3 -
- Token 10: It is an operand. Push onto stack.
Stack: [10]
- Token 2: It is an operand. Push onto stack.
Stack: [10, 2]
- Token 8: It is an operand. Push onto stack.
Stack: [10, 2, 8]
- Token *: It is an operator.
- Pop op2 = 8
- Pop op1 = 2
- Compute: $2 \times 8 = 16$. Push 16 onto stack.
Stack: [10, 16]
- Token +: It is an operator.
- Pop op2 = 16
- Pop op1 = 10
- Compute: $10 + 16 = 26$. Push 26 onto stack.
Stack: [26]
- Token 3: It is an operand. Push onto stack.
Stack: [26, 3]
- Token -: It is an operator.
- Pop op2 = 3
- Pop op1 = 26
- Compute: $26 - 3 = 23$. Push 23 onto stack.
Stack: [23]
- The expression is completely evaluated, and the final value left on the stack is 23.

Step 4: Final Answer:

The final evaluated output of the postfix expression is 23.
Hence, option (A) is the correct choice.
Was this answer helpful?
0


Questions Asked in CUET (UG) exam