Question: Write the C++ code for a void function that receives four int variables: the first two by value and the last two by reference. Name

Write the C++ code for a void function that receives four int 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 should also calculate the difference between the two variables passed by value and then store the result in the second variable passed by reference. When calculating the difference, always subtract the smaller number from the larger number. Name the function calcSumAndDiff. Also write an appropriate function prototype for the calcSumAndDiff function. In addition, write a statement that invokes the calcSumAndDiff function, passing it the num1, num2, numSum, and numDiff variables.

Step by Step Solution

3.45 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

void calcSumAndDiffint n1 int n2 int sum int diff sum n1 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Microsoft Visual C# Introduction Questions!