C++:Program Swapping variables

How to swap three nos. without another variable.
let input be a=2,b=3 and c=4
and output=a=4,b=2and c=3
using namespace std;

int main(){
int a,b,c;
cout<<"Enter three nos."<<endl;
a=a+b+c; //now a=9
b=a-(b+c); //b=2
c=a-(b+c); //c=3
a=a-(b+c); //a=4
cout<<"a="<<a<<" b="<<b<<" c="<<c;
return 0;
This method will not work for large value of integers.
                < Happy Coding > In Association with Amazon.in

Popular Posts

Top 10 Web Sites Every Programmer Should Visit Daily

How do I improve my logical thinking and problem solving skills?

C++: STL Iterators