What is the value of the postfix expression 6 3 2 4 + – *?

  • A. a) 74
  • B. b) -18
  • C. c) 22
  • D. d) 40
Correct Answer: B. b) -18
Postfix notation evaluates expressions by processing operands first, followed by operators.

Given expression: 6 3 2 4 + - *

Scan the expression from left to right:

6, 3, 2, 4: These are operands, so we push them onto a stack.

+: We encounter an operator. Pop the top two elements from the stack (4 and 2), add them (4 + 2 = 6), and push the result (6) back onto the stack.

-: We encounter another operator. Pop the top two elements from the stack (6 and 3), subtract them (3 - 6 = -3), and push the result (-3) back onto the stack.

*: We encounter the last operator. Pop the top two elements from the stack (6 and -3), multiply them (6 * -3 = -18), and push the result (-18) back onto the stack.

Since we've reached the end of the expression, the final result is the only element left on the stack, which is -18.

Therefore, the value of the postfix expression 6 3 2 4 + - * is -18.

If you think there is any confusion in the given MCQs, you can comment below.

Follow us on WhatsApp

docmcqs.com is Pakistan's No.1 online platform for preparing for all types of exams including PPSC, FPSC, KPSC, SPSC, Ministry of Defence, and for one-paper MCQs. This includes Pedagogy MCQs, general knowledge MCQs, current affairs MCQs, and much more.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top