Question: You will write a program to evaluate and display a prefix expression using a stack, not recursion. It is easy to evaluate a prefix expression

You will write a program to evaluate and display a prefix expression using a stack, not recursion.
It is easy to evaluate a prefix expression starting at the end, saving each operand until you encounter an operator, which will operate on the two operands you last encountered (saved).
You will use the linked stack ADT provided with the assignment. This ADT was covered in Chapter 7. The files are attached to this assignment. It is not necessary to make any changes to the ADT files.
The expression will contain single integer operands and only binary operators +,-,/,*.
Your main should ask the user to enter a valid prefix expression. You can assume they will enter a valid prefix expression that follows the restrictions. Your main should pass the expression to a function that evaluates and returns the calculated value. The main should display a message for the user.
Write your program using a sentinel controlled while loop to continue to read and evaluate prefix expressions until the user enters the sentinel. You pick the sentinel value.
Sample input :+-*3481=5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!