In this quick C programming tutorial, we walk through how to swap the values of two variables without using a temporary third variable. By using simple arithmetic addition and subtraction.
The Logic Explained:
Let a = 10 and b = 20.
a = a + b; (a becomes 30)
b = a - b; (b becomes 30 - 20 = 10)
a = a - b; (a becomes 30 - 10 = 20)
The variables are now swapped.
#CProgramming #CodingTutorial #ProgrammingLogic #VSCode