Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. Perform Operations (20 marks) Write a C program to implement calculator using pointers. You should ask the user two operands and what kind
3. Perform Operations (20 marks) Write a C program to implement calculator using pointers. You should ask the user two operands and what kind of arithmetic operation the user wants to run on them. This shouldn't be just a onetime operation, the user should be able to input the operands and the kind of operation which it wants to be performed on them as long as he wants to. Users may enter 'Q' to quit the program. You need to write separate function for all the operations (+,-, *, /). In these functions you need to pass the variables as pointers and then perform the requested operation and return the result. To calculate the result, you should not use a third variable. For example: Consider the function int sum(int *a, int *b); Here, the addition of two numbers must be stored in 'a' and returned. Implementation Details: */ Function: addition, subtraction, multiplication, division Perform operations on two integers using pointers. Parameters: a: Pointer to the first integer. b: Pointer to the second integer. Returns: void void addition(int *a, int*b); void subtraction(int *a, int*b); void division (int *a, int*b); void multiplication (int *a, int*b); Sample run: Enter the operation you want to perform('+' for Addition,'-' for Subtraction,'*' for Multiplication, '/' for Division, Q to quit): + Enter the operands for this operation : 78 Addition of 7 and 8 = 15 Enter the operation you want to perform('+' for Addition,'-' for Subtraction,'*' for Multiplication, '/' for Division, Q to quit): - Enter the operands for this operation: 109 9 Subtraction of 109 and 9 = 100 Enter the operation you want to perform('+' for Addition,'-' for Subtraction,'*' for Multiplication, '/' for Division, Q to quit): Q Goodbye!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Here is a C program that implements a calculator using pointers for addition subtraction multiplicat...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