Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions