Wednesday, 15 May 2013

Swapping value of two variables without third variable


#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
cout<<"enter the value of a";
cin>>a;
cout<<"\n Enter b";
cin>>b;  
a=a+b;  
b=a+b;  

a=b-a;    
b=-1*(a-b)-a;

cout<<"\n a is"<<a;
cout<<"\n b is"<<b;
getch();
}

No comments:

Post a Comment

full details in json
Proudly Powered by Blogger.
back to top