Thursday 3 July 2014

Program to swap the content (interchange) of two variables




//Swapping the contents of two variables
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,temp;
cout<<"ENTER TWO INTEGER NUMBERS:";
cin>>a>>b;
cout<<"BEFORE SWAPPING A="<<a<<"\tB="<<b;
temp=a;
a=b;
b=temp;
cout<<"\nAFTER SWAPPING A="<<a<<"\tB="<<b;
getch();

No comments:

Post a Comment