The conversation between human and AI assistant.
Write a c program to swap two numbers without using 3rd variable?
That's great, but could you explain how it works?
Sure, it works by using basic arithmetic operations. First, we add the two numbers and store them in the first variable. Then, we subtract the second variable from the sum, which gives the original value of the first variable. Finally, we subtract the first variable from the sum, which gives the original value of the second variable. Thus, the values are swapped without using a third variable.