C++ Programming/Exercises/Functions

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

[edit] EXERCISE 1

Write a program with a function that takes two int parameters, adds them together, then returns the sum. The program should ask the user for two numbers, then call the function with the numbers as arguments, and tell the user the sum.


[edit] EXERCISE 2

Basically the same as exercise 1, but this time, the function that adds the numbers should be void, and takes a third, pass by reference parameter; then puts the sum in that.