Explore a little.C ProgrammingC++HTMLVisual BasicSystem AnalysisE-CommerceBCA Notes
LEARN SOMETHING NEW

C++ Program to Swap Two Numbers

Read4BCA learning libraryFree access

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

C++ Program to Swap Two Numbers example

You can also see a video how to run this program

This lesson preserves the original Read4BCA material. Some programming examples use older tools and syntax. View original page.