C++ Programming Code Examples C++ > Beginners Lab Assignments Code Examples enter the two number to swap them and display the output on the screen enter the two number to swap them and display the output on the screen To swap two numbers in C++ programming, you have to first ask to the user to enter the two number, and store both the number in the variable say num1 and num2. Now to swap both the number, first, make a variable say swap of same type. Now place first number in the swap, then place second number in the first, and then place swap in the second. After swapping the two number, print it on the screen as shown here in the following program. Following C++ program ask to the user to enter the two number to swap them and display the output on the screen : #include<iostream.h> #include<conio.h> void main() { clrscr(); int num1, num2, swap; cout<<"Enter two number : "; cout<<"\nFirst Number : "; cin>>num1; cout<<"Second Number : "; cin>>num2; swap=num1; num1=num2; num2=swap; cout<<"The value of first and second number after swapping is \n"; cout<<"First Number = "<<num1<<"\n"<<"Second Number = "<<num2; getch(); }