C language, CS.

 A postfix expression is an expression in which each operator follows its operands. Table 13.4 shows several examples of postfix expressions. The grouping marks under each expression should help you visualize the operands for each operator. The more familiar infix expression corresponding to each postfix expression is also shown. The advantage of the postfix form is that there is no need to group subexpressions in parentheses or to consider operator precedence. The grouping marks in Table 13.4 are only for our convenience and are not required. You may have used pocket calculators that require the entry of expressions in postfix form. Use an adaptation of your stack library from Project 3 to write a program that simulates the operation of a calculator by scanning an integer expression in postfix form and displaying its result. Your program should push each integer operand onto the stack. When an operator is encountered, the top two operands are popped, the operation is performed on its operands, and the result is pushed back onto the stack. The final result should be the only value remaining on the stack when the end of the expression is reached. 

Tags: No tags