C++ Program to Swap Variables

C++ Program to Swap Variables

Swap variables in C++ :

#include <iostream> using namespace std; int main() { int x,y,z; cout << "Input First Number = "; cin >> x; cout << "Input Second Number = "; cin >> y; cout << "First Number = "<< x <<" and Second Number = "<< y <<" before Swapping\n"; z=x; x=y; y=z; cout << "First Number = "<< x <<" and Second Number = "<< y <<" after Swapping\n"; return 0; }

Output :