# Swapping of two No.s

Using temp variable

int a,b,temp;

temp = a;

a = b ;

b = temp;

Without using any temp variable

int a,b;

a = a+b;

b = a-b;

a = a-b;

Swap in just one statement !!

b=a+b-(a=b)

or

a=a+b-(b=a)

Using temp variable

int a,b,temp;

temp = a;

a = b ;

b = temp;

Without using any temp variable

int a,b;

a = a+b;

b = a-b;

a = a-b;

Swap in just one statement !!

b=a+b-(a=b)

or

a=a+b-(b=a)