Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

I need help finishing my code I have started and I have got it to run but my teacher is asking for more requirement and

I need help finishing my code I have started and I have got it to run but my teacher is asking for more requirement and I need help finishing and explaining it, please

This is my code that I need help with

// // main.c // lab 5 CS 1412 // // Created by Adebowale Adejumobi on 2/21/20. // Copyright 2020 Wale Adejumobi. All rights reserved. // #include #include #include int main(){ char arth; float user_input=0; float result=0; while(1){ scanf("%c %f", &arth,&user_input ); if(arth == '+'){ result+= user_input; printf("Results So Far , %.2f ",result); } if(arth == '-'){ result-= user_input; printf("Results So Far , %.2f ",result); } if(arth == '*'){ result*= user_input; printf("Results So Far , %.2f ",result); } if(arth == '/'){ result/= user_input; printf("Results So Far , %.2f ",result); } if(arth == '^'){ result=pow(result,user_input); printf("Results So Far , %.2f ",result); } if(arth == 'q') exit(0); } }

And This is the Requirement that the code needs to go by image text in transcribed

1. 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 QO final result is 12.5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions