Question: Code is in c. Need main.c, math.h, math.c. A small calculator We've seen enough now that you can start writing some simple but useful code.

A small calculator We've seen enough now that you can start writing some simple but useful code. For this assignment, you'll write a six-function calculator that returns the result of addition, subtraction, multiplication, division, and raising a number to a power (in two different ways). You'll turn this in using GitLab, and we'll provide instructions on how to set that up separately. The problem: Overview There are of course a lot of approaches to writing a calculator, but for this assignment there's just one. Here's what you'll need to do: Use a do-while loop to prompt the user to enter a mathematical expression. For this calculator, expressions are in a fixed format (use %f%c%f): NumberOperatorNumber For example, if you'd like to add 5 and 12 together, the expression would be 5+12 with no spaces between the numbers and the operator. The operators are: +, - /,^ (for power) and $ (for recursive power). By 'power' I mean something like 25. Use scanf to read in each of the three values (two numbers and an operator) from the fixed- format expression. If the user enters an incorrectly formatted expression, horrible things will happen and you'll likely need to halt the program manually. (Why? The scanf() function has some pretty serious problems around input that doesn't exactly match its format specifier. There are better solutions in C, but we still need to talk about a few language features before we can use them.] Once you have all three values, use a switch statement to execute one of six functions (one for each operator). The functions should be named: add, subtract, multiply, divide, power, and recursivePower Finally print the result in the format: Result:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
