Suppose x = 6, y = 2

x = x + y // (6+2=8)

y = x - y // (8-2=6)

x = x - y // (8-6=2)

**Now, x = 2 & y = 6**

The other way is:

x = x ^ y;

y = y ^ x;

x = x ^ y;

*here, ^ is bit-wise x-or operation in Computer Science*

Suppose x = 6, y = 2

x = x + y // (6+2=8)

y = x - y // (8-2=6)

x = x - y // (8-6=2)

**Now, x = 2 & y = 6**

The other way is:

x = x ^ y;

y = y ^ x;

x = x ^ y;

*here, ^ is bit-wise x-or operation in Computer Science*

No vote yet

1 vote

×

Problem Loading...

Note Loading...

Set Loading...

## Comments

Sort by:

TopNewestIf someone know much better please share with us... – Reajul Haque · 8 months, 1 week ago

Log in to reply