DEV Community

Discussion on: Swap two integers in 'C' programming Without using third variable

Collapse
 
semiversus profile image
Günther Jena • Edited

It also works with XOR (avoiding the overflow problem):

a = a ^ b
b = a ^ b
a = a ^ b
Enter fullscreen mode Exit fullscreen mode
Collapse
 
codemouse92 profile image
Jason C. McDonald

Agreed, this is definitely the way to do it.