Created
September 18, 2013 14:57
-
-
Save Zulqurnain/6610394 to your computer and use it in GitHub Desktop.
Swap two variables without using third variable. C/ C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream.h> | |
int main(){ | |
int x=1,y=2; | |
cout<<"x :=:"<<x<<"\ny :=:"<<y<<"\n"; | |
x+=y; | |
y=x-y; | |
x-=y; | |
cout<<"\nx :=:"<<x<<"\ny :=:"<<y<<"\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment