Tag Cloud

Showing posts with label tips. Show all posts
Showing posts with label tips. Show all posts

Friday, December 9, 2011

Swap two numeric variables

A simple tips to swap two numeric variables!

Imagine that you have two numeric variables. a and b

int a = 5;
int b = 8;

// Swap numbers
a = a ^ b;
b = b ^ a;
a = a ^ b;

Now the numbers is swapped.