employer cover photo
employer logo
employer logo

NetSol Technologies

Is this your company?

NetSol Technologies interview question

Swap two numbers without using third variable

Interview Answer

Anonymous

Nov 16, 2020

int a=5, b=10; Console.WriteLine("Before swap a= "+a+" b= "+b); a=a+b; //a=15 (5+10) b=a-b; //b=5 (15-10) a=a-b; //a=10 (15-5) Console.Write("After swap a= "+a+" b= "+b);

1