Question
Create the following program in Visual Studio in C. Write a small program that calculates the sum and the difference of two integers with three
Create the following program in Visual Studio in C.
Write a small program that calculates the sum and the difference of two integers with three user-defined functions: //takes two integer arguments and returns the sum of the two arguments
int CalculateSum (int num1, int num2); //takes two integer arguments and returns the difference of the two arguments
int CalculateDifference(int num1, int num2); //takes two integer arguments and two integer pointer arguments //1. calculate the sum and stores the result in sumptr //2. calculate the difference and store the result in diffPtr void CalculateBoth(int num1, int num2, int*sumPtr, int *diffPtr); Call all three functions from main. Print all the results inside the function definitions (value at) and ALSO print the results again back in the main function after the function has been called.
Main function logic (and hints):
1. Declare variables num1, num2, sum1, diff1, sum2, diff2
2. Ask and get 2 numbers from the user (num1 and num2)
3. Pass num1 and num2 to the function CalculateSum and it will return the sum to the variable sum1
4. Print sum1 onto the screen
5. Pass num1 and num2 to the function CalculateDifference and it will return the difference to the variable diif1
6.Print diff1 onto the screen
7. Pass num1 and num2 and address of sum2 and address of diff2 to the function CalculateBoth
8. Print sum2 and diff2 results onto the screen
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