Q. Evaluate following postfix expressions while showing status of stack after each operation given A=3, B=5,C=1, D=4
 

a) A B + C *

b) A B * C / D *


Answer :-

a =
AB + C *      ------ 3 5 + 1 *
(A + B) C *    ------ ( 3+5 ) 1*
( A + B ) * C   ------ 8 * 1  = 8

b=
A B * C / D *   ------- 3 5 * 1 / 4 *     
( A*B ) C / D *  ------- ( 3 * 5 ) 1 / 4 *
(A*B) / C D *   ------- ( 15 ) / 1 4 *
((A*B) / C )* D  ------- ( 15 ) * 4 = 60


Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post