Skip to content

re: How can you swap two variables without using a third? VIEW POST


(Posting before reading the other comments) I came up with two solutions, not sure if there's any reason either would be considered superior:

a = a + b
b = b - a
a = a + b
b = -b
a = a + b
b = b + a
a = b - a
b = b - 2*a
code of conduct - report abuse