Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use C. Write a program calc.c that implements a simple arithmetic calculator. Input to the calculator consists of lines composed of integer constants separated
Please use C. Write a program calc.c that implements a simple arithmetic calculator. Input to the calculator
CH. 10: (pg. 367-372) 10. calc.c (diff calc_output with our output file, our example uses, here is the Input 2+3*4 (INPUT expression)) [ENTER] (Make sure you "enter" this is the termination case DONT TYPE THIS) Write a program calc.c that implements a simple arithmetic calculator. Input to the calculator consists of lines composed of integer constants separated by the five arithmetic operators use in C: +, -, *, /, and %. For each line of input, your program should display the result of applying the operators to the surrounding terms. To read the individual values and operators, you should use the scanner module as extended in exercise 9, so that spacing is ignored. Your program should exit when the user enters a blank line. To reduce the complexity of the problem, your calculator should ignore C's rules of precedence and instead apply the operators in left-to-right order. Thus, in your calculator program, the expression 2 + 3 * 4 has the value 20 and not 14, as it would in C. The following is a sample run of the calc.c program: program implements a simple calcu when the prompt appears, enter an consisting of integer constants and -, * 7, and . To stop. enter a bi > 2 + 20 le calculator ter an expression and the operators iter a blank 1100 > 1. 2+ 34+ 5. 15 > 10 $ 4- 4.9-2016+1/396-67-8-2-326-1/34+3/742-5 consists of lines composed of integer constants separated by the five arithmetic operators used
in C: +, -, *, /, and %. For each line of input, your program should display the result of applying
the operators to the surrounding terms. To read the individual values and operators, you should
use the scanner module as extended in exercise 9, so that spacing is ignored. Your program
should exit when the user enters a blank line.
To reduce the complexity of the problem, your calculator should ignore Cs rules of precedence
and instead apply the operators in left-to-right order. Thus, in your calculator program, the
expression
2 + 3 * 4
has the value 20 and not 14, as it would in C.
The following is a sample run of the calc.c program:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started