Important Questions

C++ Program to Swap Two Numbers

//C++ Program to Swap Two Numbers
//header files
#include<iostream.h>
#include<conio.h>

void main()
{

clrscr();
int a = 8, b = 16, temp;
cout << "Before swapping." << endl;
cout << "a = " << a << ", b = " << b << endl;
temp = a;
a = b;
b = temp;
cout <<"\nAfter swapping." << endl;
cout << "a = " <<a << ", b = " <<b << endl;
getch();

}

Output


You can also see a video how to run this program