How to swap Two integers variable values without using a third variable?
How to swap Two integers variable values without using a third variable?
Student
Tamplet designer as a part-time and full-time football addict. Graduated from Aligarh Muslim University with having Bachelor of Science and currently working and playing in my life.
Sure, here is a C# code that swaps two integers without using a third variable:
C#
This code works by adding x and y together, then storing the result in x. Then, it subtracts y from the result, and stores the result in y. Finally, it subtracts x from the result, and stores the result in x. This effectively swaps the values of x and y without using a third variable.
Here is an explanation of how the code works:
There is a simple C# program to swap to an integer without using a third variable.