Swapping of two No.s

Akhilesh Sinha

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 !!



Like what you read? Give Akhilesh Sinha a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.