. Write a simple calculator program calc.c, that prompts the user a first operand, an operator,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
. Write a simple calculator program calc.c, that prompts the user a first operand, an operator, and a second operand, then computes the result. Use a switch statement to decide whether to perform addition, subtraction, multiplication, or division based on the operators +, -, *or / characters. Hint: the argument of the switch statement, the operator, is a character data type (char). Sample output: Enter x, operator, y: 12 + 30 12.000000+30.000000 = 42.000000 Enter x, operator, y: 5 3 5.000000*3.000000 = 15.000000 Enter x, operator, y: 5 * 3 5.000000*3.000000 = 15.000000 Enter x, operator, y: 7/2 7.000000/2.000000 = 3.500000 Enter x, operator, y: 120 can't divide by 0, buddy! Enter x, operator, y: 12 % 6 Invalid operator! . Write a simple calculator program calc.c, that prompts the user a first operand, an operator, and a second operand, then computes the result. Use a switch statement to decide whether to perform addition, subtraction, multiplication, or division based on the operators +, -, *or / characters. Hint: the argument of the switch statement, the operator, is a character data type (char). Sample output: Enter x, operator, y: 12 + 30 12.000000+30.000000 = 42.000000 Enter x, operator, y: 5 3 5.000000*3.000000 = 15.000000 Enter x, operator, y: 5 * 3 5.000000*3.000000 = 15.000000 Enter x, operator, y: 7/2 7.000000/2.000000 = 3.500000 Enter x, operator, y: 120 can't divide by 0, buddy! Enter x, operator, y: 12 % 6 Invalid operator!
Expert Answer:
Answer rating: 100% (QA)
calc include stdio h float calculatefloat x char op float y switchop case return x ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
You have been provided with the description of a programming language, J, intended for scripting applications. Its syntax is similar to a cut-down version of Java in that it consists of function...
-
4 Comparative Programming Languages illustrating your answer by explaining the meaning of the following fragment of code: [self isAwake] whileTrue: [| item | item := self askForCookie. (self...
-
Be able to explain how changes in transportation impacted economic growth in the United States prior to WWI.
-
The price of tools is set by a hardware store to cover operating expenses at 40% of cost, and to generate an operating profit of 25% of cost. What is the rate of markup on selling price for a rotary...
-
What is the difference between each pair of items? a) Listed and unlisted securities b) Brokers and market makers c) Full-service and discount brokerage firms d) Primary and secondary markets e)...
-
Explain how crossover, mutation, and reproduction affect schemata.
-
Cost-plus and market-based pricing California Temps, a large labor contractor, supplies contract labor to building-construction companies. For 2009, California Temps has budgeted to supply 80,000...
-
1. Project x-ray is being considered for an expansion of current capabilities of the company given below is the necessary financial information to solve the problem. The initial investment is: $...
-
Parker Company borrowed $150,000 and signed a 5-year 4% note requiring monthly payments that would consist of a fixed amount of principal with interest added on. Payments are due at the end of each...
-
You plan to deploy a dockerized application in an AWS ECS cluster. The application needs access to an S 3 bucket to read files. The ECS containers should have the AmazonS 3 ReadOnlyAccess permission....
-
Write the function sum2.m that accepts a matrix m and returns the summation of the positive numbers and the summation of the negative numbers in m. The outputs are sum_p, and sum_n. Use the function...
-
For this exercise, instead of using the values in the challenge, ask the user for the number of shares, the share price, and the percent commission.For this exercise, instead of using the values in...
-
One key feature of Sage 50 Accounting software, it implements user access controls to restrict access to sensitive financial data. Maintain the security of financial information with password...
-
How will the Information Assurance program benefit you in the future?
-
Use an organization that is popular in US and review the mission statement of a community sport organization and report back to us: The name of organization What the mission statement says (in your...
-
Express these numbers in standard notation. a. 2.87 10-8 b. 1.78 1011 c. 1.381 10-23
-
\(X\) is the number of bits in error in the next four bits transmitted. What is the expected value of the square of the number of bits in error? Now, \(h(X)=X^{2}\). Therefore, \[ \begin{aligned}...
-
Proportion of US adults who own a cell phone. In a survey of 1006 US adults in 2014, 90% said they had a cell phone. Give the correct notation for the quantity described and give its value.
-
In March 2015, a Nielsen global online survey "found that consumers are increasingly willing to pay more for socially responsible products." Over 30,000 people in 60 countries were polled about their...
Study smarter with the SolutionInn App