Write a C program to swap 2 numbers without using temporary variable
Anonym
I'll just write the basic algorithm that can be used. Let's have two variables x = 10 and y = 15. We want to swap the values of x and y without using a third variable. 1. Put x = x+y ====> X = 10 + 15 = 25 2. y = x - y ====> Y = 25 - 15 = 10 3. x = x - y ====> X = 25 - 10 = 15 Finally we have x =15 and y = 10 and the values are now swapped