In this lab, you complete a partially written 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. The source code file provided for this lab includes the necessary variable declarations and input and output statements. Comments are included in the file to help you write the remainder of the program. 1. Open the source code file named AddThree.cpp using Notepad or the text editor of your choice. 2. Write the addNumbers ) function, the function declaration, and the function call as indicated by the comments. 3. Save this source code file in a directory of your choice, and then make that directory your working directory. 4. Compile the source code file AddThree.cpp. 5. Execute the program. 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. 9. Execute the program. Both programs (AddThree.cpp and AddThree2 .cpp) should generate the same output.
In this lab, you complete a partially written C++
1. Open the source code file named AddThree.cpp using Notepad or the text editor of
your choice.
2. Write the addNumbers ) function, the function declaration, and the function call as
indicated by the comments.
3. Save this source code file in a directory of your choice, and then make that directory
your working directory.
4. Compile the source code file AddThree.cpp.
5. Execute the program.
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.
9. Execute the program. Both programs (AddThree.cpp and AddThree2 .cpp) should generate the same output.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images