swap-without-third-variable


  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main(){
  4. clrscr();
  5. int x,y;
  6. cout<<"\nenter first integer :";
  7. cin>>x;
  8. cout<<"\nenter second integer :";
  9. cin>>y;
  10. cout<<"\nthe original value in x="<<x<<" "<<"and y="<<y;
  11. x=x+y;
  12. y=x-y;
  13. x=x-y;
  14. cout<<"\nthe swapped value in x="<<x<<" "<<"and y="<<y;
  15. getch();
  16. }