Write a program that acts as a basic calculator Assume the starting result is 0 Ask the
Question:
Write a program that acts as a basic calculator Assume the starting result is 0 Ask the user for the operation to be performed 0 – Exit 1 – Add 2 – Subtract 3 – Multiply 4 – Divide (Assume input will not be 0) Keep on performing the operation and showing the result until the user inputs the ‘0’ (exit) operation. You need to have everything written as functions E.g. - You should only have the options listed once in the code You should have 4 different functions for each operation. Any 2 of these functions should not return anything but instead use parameter passing by reference/pointers. The other 2 functions should pass the parameter by value and have return statements (make sure to have a way to restrict the users to not make any changes to the original result variable). Your main function should be just the following lines please use #include studio not ios.stream int main(int argc, char* argv[]) { calculator(); return 0; } /* Sample run of the program - Input and Output */ 0 - Exit 1 - Add 2 - Subtract 3 - Multiply 4 - Divide Please select an option : 1 Please enter the value : 5 Result = 5.000000 0 - Exit 1 - Add 2 - Subtract 3 - Multiply 4 - Divide Please select an option : 2 Please enter the value : 1 Result = 4.000000 0 - Exit 1 - Add 2 - Subtract 3 - Multiply 4 - Divide Please select an option : 3 Please enter the value : 3 Result = 12.000000 0 - Exit 1 - Add 2 - Subtract 3 - Multiply 4 - Divide Please select an option : 4 Please enter the value : 2 Result = 6.000000 0 - Exit 1 - Add 2 - Subtract 3 - Multiply 4 - Divide Please select an option : 0
Database Systems A Practical Approach to Design Implementation and Management
ISBN: 978-0132943260
6th Edition Global
Authors: Thomas Connolly, Carolyn Begg