DEV Community

Discussion on: Swap two integers in 'C' programming Without using third variable

Collapse
 
fpuffer profile image
Frank Puffer • Edited

While it does have some educational value to show that this is possible, this method has two issues:

  • Both a = a + b and a = a - b can cause an overflow.

  • I can't imagine many situations where saving a few bytes really makes up for the loss in readability.