// ;----------------------------------------------------------- // ; Program Name: Class_Demo // ; File: Swap.cpp // ; Description: Swaps two variables using a function // ; Author: Jim Adams // ; Environment: MS C++ 6.0 // ; Date Written: 07/13/2001 // ;----------------------------------------------------------- #include void get_input(int& n1, int& n2); // Prototype, formal parameters void swap(int& n1, int& n2); void main(void) { int first_num, second_num; get_input(first_num, second_num); swap(first_num, second_num); cout << "Number One Entered:" << first_num << endl; cout << "Number Two Entered:" << second_num << endl; } // Get user input // prompt user for 2 integers // Pass values back through passed arguments void get_input(int& num1, int& num2) { cout << "Enter Number One:"; cin >> num1; cout << "Enter Number Two:"; cin >> num2; } // Swap the values that are passed // Pass values back through passed arguments void swap(int& num1, int& num2) { int temp; temp = num1; num1 = num2; num2 = temp; }