Programming in C
Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 5, Problem 4E

Write a program that acts as a simple “printing” calculator. The program should allow the user to type in expressions of the form

n

The following operators should be recognized by the program:

+

The S operator tells the program to set the “accumulator” to the typed-in number. The E operator tells the program that execution is to end. The arithmetic operations are performed on the contents of the accumulator with the number that was keyed in acting as the second operand. The following is a “sample run” showing how the program should operate:

B

10 S

=

2 /

55 –

-

100.25 S

=

4 *

=

0 E

=

E

Make certain that the program detects division by zero and also checks for unknown operators.

Blurred answer
Students have asked these similar questions
Write a program that mimics a calculator. The program should take as input two integers and the operation to be performed. It should then output the numbers, the operator, and the result. For division, if the denominator is zero, output an appropriate message. Limit the supported operations to + -/ *and write an error message if the operator is not one of the supported operations. Here is some example output: 3 + 4 = 7 13 * 5 = 65   C++
3)Write a program which prompts the user for their age. If they are 19 or younger inform them that qualify for student discounts. If they are between 20 and 65 inform them that they qualify for no age discounts. If they are 65 or over inform them that they can receive senior discounts. (solution will be Pyhton code,thank you)4)Write a program from decimal to any base, ask the user for a decimal number and convert entered base by user. (Your program should support bases between 2 and 16 .) (solution will be Pyhton code,thank you)
Write a program that performs as a very simple calculator. Your calculator should be able to handle the four basic math operations — add, subtract, multiply, and divide — on two input values. Your program should prompt the user to enter three arguments: two double values and a character to represent an operation. If the entry arguments are 35.6, 24.1, and '+', the program output should be The sum of 35.6 and 24.1 is 59.7.

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Introduction to Operators in C; Author: Neso Academy;https://www.youtube.com/watch?v=50Pb27JoUrw;License: Standard YouTube License, CC-BY