algorithms.tutorialhorizon.com

Given two numbers, swap both the numbers using XOP operators. | Algorithms

XOR operator can be used to swap two variables. • Do x = x XOR y, this will set only the bits which are set either in x or in y. store it in x. • Do y = x XOR y, this will set the bits which were set in original x so this will store the original value of x into y. • Do x = x XOR y, this will set the bits which were set in original y so this will store the original value of y into x.