Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the C++ code for a void function that receives four i nt variables: the fi

ID: 3657077 • Letter: W

Question

Write the C++ code for a void function that receives four i nt variables: the first two by value and the last two by reference. Name the formal parameters n1, n2, sum, and diff. The function should calculate the sum of the two variables passed by value and then store the result in the first variable passed by reference. It also should calculate the difference betweenthe two variables passedby valueandthenstore the result in the second variable passed by reference. When calculating the difference, subtract the contents of the n2 variable from the contents ofthe n1 variable. Name the function cal cSumAndDiff. Also write an appropriate function prototype for the cal cSumAndDi ff function. In addition, write a statement that invokes the cal cSumAndDi ff function, passing it the num1, num2, numSum, and numDiff variables.

Explanation / Answer

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 #include #include using namespace std; //function prototype void calcSumAndDiff(int n1, int n2, int sum, int diff); int main() { //declare variables int num1 = 0; int num2 = 0; int numSum = 0; int numDiff = 0; //get input items cout > num1; cout > num2; //Adding and subtracting the numbers calcSumAndDiff(num1, num2, numSum, numDiff); //display the sum and difference cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote