Swap Two Numbers without using Temp Variable
You can do it with some XORs:int a = 25, b = 7;a = a ^ b;b = b ^ a;a = a ^ b;Or the same thing with some shorthand to make the code even harder to read:a ^= b;b ^= a;a ^= b;
You can do it with some XORs:
int a = 25, b = 7;
a = a ^ b;
b = b ^ a;
a = a ^ b;
Or the same thing with some shorthand to make the code even harder to read:
a ^= b;
b ^= a;
a ^= b;