C++ program for swapping of two variable without using third variable.

#include<iostream.h>
#include<conio.h>
void main(){
int a,b;
clrscr();
cout<<"Enter two item"<<endl;
cin>>a>>b;;
cout<<"Before Swapping \n Your Two Item.\n"<<"A = "<<a<<"\n"<<"B = "<<b<<endl;
getch();
a=a+b;
b=a-b;
a=a-b;
cout<<"After Swapping \n "<<"A = "<<a<<"\n"<<"B = "<<b<<endl;
getch();
}

No comments:

Post a Comment