Swapping two number without using third variable in C#

Amatya
Posted by Amatya under C# category on | Points: 40 | Views : 466
Swapping two number without using third variable in C#

    int num1;
int num2;
num1 = 1;
num2 = 2;

num1 = num1 + num2;
num2 = num1 - num2;
num1 = num1 - num2;


After using this code snippet the value of num1 will be 2 and value of num2 will be 1

Thanks
Amatya

Comments or Responses

Login to post response