Friday, 5 June 2015

Q21,paper2 ,D13. What is the value of the postfix expression ? a b c d + – ∗ (where a = 8, b = 4, c = 2 and d = 5)



(A) –38
(B) –83
(C) 24
 (D) –24

Answer D.

Explanation.
Push 8
Push 4.
Push 2.
Push 5. Stack contents are (8425).
Read +, pop two elements , do operation , and push in the stack. Stack is(847).
Read -,Pop two elements ,do operation (4-7=-3), push three in stack. Stack is(8,-3).
Read *, Pop two elements ,do operation (=-24), push three in stack. Stack is(-24).
Answer is -24

No comments:

Post a Comment

Note: only a member of this blog may post a comment.