Question: C PROGRAM create a new file calc.c which implements a simple calculator. The calculator will perform the four basic arithmetic operations +, -, * and
C PROGRAM
create a new file calc.c which implements a simple calculator. The calculator will perform the four basic arithmetic operations +, -, * and /. The program should prompt the user for the operation to perform in an endless loop. For example:
calc > 3 + 6
9
calc >
You must implement the calculator such that there is one calc function which takes as arguments the numerical values of the two operands and a pointer to the specified function (add for +, etc), plugs the two values into the referenced function, and returns the result.
Your program should work independent of spaces in the input. For instance, both 1+2 and 1 + 2 should work. This is actually very easy to do with scanf
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
