Write the C++ code for a void function that receives four int variables: the first two by

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 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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: