is it possible to swap the value of two variables without using a third variable

1 reply [Last post]
Last seen: 7 years 16 weeks ago
Joined: 2012-07-03
bOt Points: 54
By using + and -

int a =5;

int b= 7;

a=a+b;//lose a now  a=5+7 = 12 b=7

b=a-b;//in b set value that was in a a=12 and b=12-7=5 nov 

 a=a-b;//in a set value from b in a=12-5=7 b=7   (now is a=7 b=5 at strat it was a=5 and b=7)