Swap two numbers without temp variable

Sakthi.Singaravel
Posted by Sakthi.Singaravel under C# category on | Points: 40 | Views : 2284
Here the code for swaping the two variable values, without using temporary variable..

int a=10;
int b=20;
a=a+b; //a=30
b=a-b; //b=30-20=10
a=a-b; //a=30-10=20

Comments or Responses

Login to post response