Switch two variables, x and y, without using the third.
Anonymous
Let us say x = 5, y = 10 x = x + y // x = 15, y = 10 y = x - y // y = 5, x = 15 x = x - y // x = 10, y =5 You can also use a bitwise operator, XOR, in case the numbers are huge (overflow when adding together) x = x^y y = y^x x = x^y
Check out your Company Bowl for anonymous work chats.