te a program to model a simple calculator. Each data line should consist of the next operation to be performed from the list below and the right operand. Assume the left operand is the accumulator value (initial value of 0). You need a function scan_data with two output parameters that returns the operator and right operand scanned from a data line. You need a function do_next_op that performs the required operation. do_next_op has two input parameters (the operator and operand) and one input/output parameter (the accumulator). The valid operators are: + add
C programing
Write a program to model a simple calculator. Each data line should consist of the next
operation to be performed from the list below and the right operand. Assume the left operand
is the accumulator value (initial value of 0). You need a function scan_data with two output
parameters that returns the operator and right operand scanned from a data line. You need a
function do_next_op that performs the required operation. do_next_op has two input
parameters (the operator and operand) and one input/output parameter (the accumulator).
The valid operators are:
+ add
- subtract
* multiply
/ divide
^ power (raise left operand to power of right operand)
q quit
Your calculator should display the accumulator value after each operation. A sample run follows.
+ 5.0
result so far is 5.0
^ 2
result so far is 25.0
/ 2.0
result so far is 12.5
q 0
final result is 12.5
![Q2) Write a program to model a simple calculator. Each data line should consist of the next
operation to be performed from the list below and the right operand. Assume the left operand
is the accumulator value (initial value of 0). You need a function scan data with two output
parameters that returns the operator and right operand scanned from a data line. You need a
function do_next_op that performs the required operation. do_next_op has two input
parameters (the operator and operand) and one input/output parameter (the accumulator).
The valid operators are:
+ add
subtract
* multiply
/ divide
power (raise left operand to power of right operand)
q quit
Your calculator should display the accumulator value after each operation. A sample run follows.
+ 5.0
result so far is 5.0
* 2
result so far is 25.0
/ 2.0
result so far is 12.5
final result is 12.5](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb6829ad2-3724-4bb4-a480-6198a16dde48%2F8d751a86-b30c-41b3-aa42-976c131cc611%2Fm37waz_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)