Swap two number in place without temporary variables

Problem Write a function to swap two number in place without temporary variables. Solution Method1 - The XOR or Exclusive trick In C this should work: a ^= b ^= a ^= b; to simplify : a=a^b; b=a^b; a=a^b; ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy