// demonstrates call-by-reference parameters. // Walt Savitch // 10/3/00 #include using std::cout; using std::endl; using std::cin; void getNumbers(int&, int&); // reads two integers from the keyboard. void swap(int&, int&); // interchanges first and second parameter. void showResults(int, int); // outputs parameters int main(){ int firstNum, secondNum; getNumbers(firstNum, secondNum); swap(firstNum, secondNum); showResults(firstNum, secondNum); } // reads two integers from user void getNumbers(int& in1, int& in2) { cout << "Enter two integers: "; cin >> in1 >> in2; } // interchanges left and right void swap(int& left, int& right) { const int tmp = left; left = right; right = tmp; } // outputs parameters void showResults(int out1, int out2) { cout << "In reverse order, the numbers are: " << out1 << " " << out2 << endl; }