+ 3

Write a program to swap two variables without using third variable? (two variables a,b. The value of a should go & b to a)

26th Jul 2017, 4:57 AM
Purvesh Jain
Purvesh Jain - avatar
3 Respuestas
+ 12
a = a + b; b = a - b; a = a - b; In Ruby, you can just do this tho: a, b = b, a There is also the bitshift method, waiting for someone to fill in.
26th Jul 2017, 4:59 AM
Hatsy Rei
Hatsy Rei - avatar