[Tutor] Swapping variables ...

O.R.Senthil Kumaran orsenthil at gmail.com
Sun Nov 11 06:35:41 CET 2007

>  After quizzing newbies in C on swapping without 3rd variable, I found this
> to be really *cool* construct to swap :)
> x = 10
> y = 20
> x,y = y,x

Keep in mind that, this is actually a tuple assignment.
A new tuple x,y is created with the older one y,x, and with the side effect thatthe variables are swapped as we see it.

yes, tuple concepts does not exist in C (as it is not a Very High Level Language).

yes, I too find it "cool" when I got introduced to it.

O.R.Senthil Kumaran

More information about the Tutor mailing list