Write a C++ program that includes a function named addNumbers() that adds three int values to find their sum. Four ints should be passed to the addNumbers() function, the three numbers to be added ( num1, num2, and num3) should be passed by value, and another int ( sum ) to hold the sum of the three numbers should be passed by reference, enabling the addNumbers() function to change its value.
1. Open the source code file named AddThree.cpp
2. Write the addNumbers ) function, the function declaration, and the function call as indicated by the comments.
4. Compile the source code file AddThree.cpp.
6. Rewrite the addNumbers ) function to pass the three numbers ( numl, num2, and num3) by value and to pass sum by address.
7. Save this program as AddThree2.cpp.
8. Compile AddThree2.cpp.
Comments
Leave a comment