Thursday, 22 August 2013

How to swap two variables in one line in C?

How to swap two variables in one line in C?

I want to know that is there any other way of swapping 2 numbers in one
line and of course without 3rd variable.
I know one way of doing this:
b=a+b-(a=b)
or
a=a+b-(b=a)
both are same(approximately). If you know then please help me out.

No comments:

Post a Comment