Answered step by step
Verified Expert Solution
Link Copied!

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
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:
image text in transcribed
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

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

3319712721, 978-3319712727

More Books

Students also viewed these Databases questions

Question

denigration of emotional outbursts; being reserved;

Answered: 1 week ago