Question: using c++: Evaluate the following postfix expressions: 12 18 - 30 + 2 * 3 / = 28 5 / 3 + 5 4 *

using c++: Evaluate the following postfix expressions: 12 18 - 30 + 2 * 3 / = 28 5 / 3 + 5 4 * - 8 + = 13 18 10 17 2 20 + - + / * = 7 3 6 2 + - + 2 * 8 + = 29 3 / 6 + 12 - 3 4 * + = What they have in mind for this exercise is for you to ask the user for a positive number which you store in an string variable. Say the user enters 21.34 You would then cycle through the characters in the string as you would items in an array. Remember, strings are based on arrays. You then type cast each character to a digit and "add" it to an integer variable. I put "add" in quotes because you will have to multiply by 10 with each new digit so that you get 21 and not 3. You would stop when you encounter a decimal and then in a separate action, take each decimal digit off the string and push each to a stack. Then when you get them all on the stack, you can use the stack to process them in an order where you can divide by 10 with each digit you pull from the stack so that they too end up as .34 and not 7. You would need a decimal variable for this portion. You can then combine the whole number and the decimal number portions into one numeric variable

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!