Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider a 0-address (stack) machine with the following instruction types, where

ID: 3931928 • Letter: C

Question

Consider a 0-address (stack) machine with the following instruction types, where M is a memory address: PUSH M push contents of M onto the stack POP M pop the stack into M ADD pop top two items, add and push the result SUB pop top two items, subtract the top one from the bottom of the two and push the result MUL pop top two items, multiply and push the result DIV pop top two items, divide the bottom of the two by the top one and push the result Write the postfix notation for the expression: (A + B * C)/(D - E * F) Write a program to compute, without destroying the original contents of A to F. X = (A + B * C)/(D - E * F) You may use additional variables if necessary. All data items are integers.

Explanation / Answer

1.

a.)

Infix expression is : ( A + B * C ) / ( D - E * F )

-> Postfix notation :

-> In postfix notation operand should be after operands.

i.e postfix notation of A + B is A B +

postfix notation of ( A + B * C ) / ( D - E * F ) :

=> ( A + B * C ) ( D - E * F ) /

=> ( A + B * C ) ( D E * F - ) /

=> ( A + B * C ) ( D E F * - ) /

=> ( A B * C + ) ( D E F * - ) /

=> ( A B C * + ) ( D E F * - ) /

=>  A B C * + D E F * - /

postfix notation of ( A + B * C ) / ( D - E * F ) is A B C * + D E F * - /

b.)

// Program for computing X = ( A + B * C ) / ( D - E * F ) using 0 - address machine instruction types

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote