Write a C program that uses arrays and functions to implement a calculator for two operands. Your calculator must have five principal operations, addition ( ), subtraction ( ), division ( ), multiplication ( ), and power ( ). In the beginning of the program, show the menu of operators to the user. When the user selects one of the operators, your program gets the values for operand 1 and operand 2 from the user and saves them into an array. Then pass the array to the suitable function to calculate the result. The operating functions must return the value to the main program. The calculation stops when the user press “x”. Use a global variable to save the result of last operation. Anytime that the user types “M”, the program shows the result of last operation. hint: Each mathematic operation must be a separate function. Your main program calls those functions.
Write a C program that uses arrays and functions to implement a calculator for two
operands. Your calculator must have five principal operations, addition ( ), subtraction ( ),
division ( ), multiplication ( ), and power ( ). In the beginning of the program, show the menu
of operators to the user. When the user selects one of the operators, your program gets the values
for operand 1 and operand 2 from the user and saves them into an array. Then pass the array to the
suitable function to calculate the result. The operating functions must return the value to the main
program. The calculation stops when the user press “x”. Use a global variable to save the result of
last operation. Anytime that the user types “M”, the program shows the result of last operation.
hint: Each mathematic operation must be a separate function. Your main program calls those functions.
Step by step
Solved in 2 steps with 2 images