// Author: Keith Shomper // Date: 2/2/04 // Purpose: To demonstrate exchanging variables #include #include using namespace std; int main() { int x = 10; int y; int t; // print out the values of x, y, and t cout << x << " " << y << " " << t << " " << endl; // prompt for and get a non-garbage value for y cout << "What value would you like for variable 'y'? "; cin >> y; // swap (or exchange) the variables x and y t = x; x = y; y = t; // print out the new values of x, y, and t cout << x << " " << y << " " << t << " " << endl; return 0; }