The following questions relate to stack arithmetic Write out

The following questions relate to stack arithmetic. Write out the following expressions from infix notation using stack expressions (example: A+B+C+D-E becomes push A, push B, add, push C, add, push D, add, push E, sub)

(A-B) * (C+D) + E

Solution

Given expression is (A-B)*(C+D)+E

we know that whenever left paranthesis occur we have to wait until right parenthesis occur when right parenthesis occur we perform the things which are in between those two paranthesis.

stack expressions:PUSH A

                             PUSH B

                              SUB                                              (A-B)

                            PUSH C

                            PUSH D

                              ADD                                                           (C+D)

                             MUL                                                               (A-B)*(C+D)

                            PUSH E

                            ADD                                                               (A-B)*(C+D)+E

The following questions relate to stack arithmetic. Write out the following expressions from infix notation using stack expressions (example: A+B+C+D-E becomes

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site