Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Introduction to Programming in C Lab Final: Calculator Program Create a program for a calculator. The calculator will have the following functions 1. Menu Function:
Introduction to Programming in C Lab Final: Calculator Program Create a program for a calculator. The calculator will have the following functions 1. Menu Function: Print down the options of operations for the user and ask the user for their choice. Input (None) Output (int) > take option from the user and return it 2. Add Function Perform addition operation on the input numbers (numl + num2) Input (int numl, int num2) Output (int) return (num1 +num2) 3. Sub Function Perform subtraction operation on the input numbers (numl - num2) Input (int num], int num2) Output (int) return (num1 - num2) 4. Multiply Function Perform multiplication operation on the input numbers (numl * num2) Input (int numl, int num2) Output (int) return (num1*num2) 5. Divide Function Perform division operation on the input numbers (numl / num2) Input (int numl, int num2) Output (int) return (num1um2) 6. Square Function Perform square operation on the input numbers (number * number) Input (int number) Output (int) return (number*number) Notes and tips You can switch statements or if statements for the different options Make sure to make a do-while loop Use the last lab to help guide you Use the image below of the functions declarations to help you start your code. int menu (); int add(int num1, int num2); int sub(int numi, int num2); int multiply(int num1, int num2); int divide(int numi, int num2); int square(int num1); Your output should look as follows 1. add 2. subtract 3. Multiply 4. Divide 5. Square 0. Exit Your choice is : 1 Number 1 : 5 Number 2 :1 5 + 1 = 61 1. add 2. subtract 3. Multiply 4. Divide 5. Square 0. Exit Your choice is : 2 Number 1 : 5 Number 2 : 2 5- 2 - 3 1. add 2. subtract 3. Multiply 4. Divide 5. Square 0. Exit Your choice is : 0 *** END PROGRAM ****** 1. add 2. subtract 3. Multiply 4. Divide 5. Square 0. Exit Your choice is : 3 Number 1 :5 Number 2:2 5 * 2 - 10 1. add 2. subtract 3. Multiply 4. Divide 5. Square 0. Exit Your choice is : 9 Wrong Option, Try Again 1. add 2. subtract 3. Multiply 4. Divide 5. Square 0. Exit Your choice is : 5 Number :6 (6)^2 = 36 1. add 2. subtract 3. Multiply 4. Divide 5. Square 0. Exit Your choice is : 0 ****** ******** END PROGRAM ******
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started