/******************************************/ /* */ /* Author: L. Frye */ /* */ /* Date: May 26, 2004 */ /* */ /* Filename: functions.cpp */ /* */ /* Description: This is a program to */ /* illustrate how functions work. */ /* */ /******************************************/ #include using namespace std; int fun1(int num1); int z; int main() { int x = 1, y = 2; cout << "x = " << x << endl; cout << "y = " << y << endl; z = 10; y = fun1(x); cout << "x = " << x << endl; cout << "y = " << y << endl; cout << "This is so much fun!" << endl; return 0; } // end main /******************************************/ /* */ /* Function name: fun1 */ /* Parameters: num1 - a whole number */ /* Return value: a different whole number */ /* Description: This function is an */ /* example to help learn about */ /* functions and what happens when the */ /* value of a parameter changes. */ /* */ /******************************************/ int fun1(int num1) { int num2 = 10; cout << "z = " << z << endl; cout << "num1 = " << num1 << endl; cout << "num2 = " << num2 << endl; num1 = num2 + 5; num2 = 50; cout << "num1 = " << num1 << endl; cout << "num2 = " << num2 << endl; return num2; } // end function fun1