sahajjain01

Swap values of two variable without using third.

Aug 4th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. //Program to swap values of two variable without using third.
  2. #include<iostream.h>
  3. #include<conio.h>
  4. void main()
  5. {
  6.     clrscr();
  7.     int a,b;
  8.     cout<<"Enter first number: ";
  9.     cin>>a;
  10.     cout<<"Enter second number: ";
  11.     cin>>b;
  12.     a=a+b;
  13.     b=a-b;
  14.     a=a-b;
  15.     cout<<"The first number is: "<<a<<endl;
  16.     cout<<"The second number is: "<<b;
  17.     getch();
  18. }
Advertisement
Add Comment
Please, Sign In to add comment