Hi all, How we can Swap the two values using XOR operation but without using third Variable?

Thanks

Thanks

Hi all, How we can Swap the two values using XOR operation but without using third Variable?

Thanks

Thanks

0

Code:

int x = 1; int y = 10; x = x^y; y = x^y; x = x^y;

Thanks

Shabbir Bhimani

0

Thanks. I was not able to start my PC and so I could not reply.

0

we can do in a single line using compound assignment tooo......

x^=y^=x^=y;

the above too will work

thank u

x^=y^=x^=y;

the above too will work

thank u

SaswatPadhi
like this