Home > DeveloperSection > Forums > How can I swap two variables without using a third variable?
Rajesh Goswami

Total Post:29

Points:203
Posted on    May-07-2011 1:07 AM

 Java Java 
Ratings:


 1 Reply(s)
 1221  View(s)
Rate this:

Problem in making a swap program in java without using a third variable.

 



Amit Singh

Total Post:103

Points:721
Posted on    May-07-2011 9:52 AM

we can swap using only two variable for example

int a=5,b=10;a=a+b; b=a-b; a=a-b;

check it.


Don't want to miss updates? Please click the below button!

Follow MindStick