#include using namespace std; int myFun( int a ); // function "prototype" void myFun2( int a ); void myFun3( int &a ); // main function int main() { int mynumber, n7; cout << "hello user! please enter a number: "; // prompt user for input cin >> mynumber; // read user's number cout << "you entered: " << mynumber << endl; // echo back user's input // call the function myFun to multiply user's number by 7 n7 = myFun( mynumber ); cout << "your number times 7 = " << n7 << endl; // now call myFun2 to change the value of 'mynumber' (but it won't work) myFun2( mynumber ); cout << "mynumber is now: " << mynumber << endl; // now call myFun3 to change the value of 'mynumber' (which will work) myFun3( mynumber ); cout << "mynumber is now: " << mynumber << endl; } // end of main() // define function int myFun( int a ) { // a is the function argument or parameter int b; // b is a local variable b = a * 7; return( b ); // return value } // end of myFun() void myFun2( int a ) { // this won't work because the value of a will a = a * 7; // not be changed outside of the function cout << "inside myFun2: a=" << a << endl; return; } void myFun3( int &a ) { // this will work because a is a reference parameter a = a * 7; // and WILL be changed outside of the function cout << "inside myFun3: a=" << a << endl; return; }