Monday, September 17, 2018

Swap two Number without using 3rd variable in c#:

            int a = 1, b = 2;
            Console.WriteLine("Before Swapping :"+a + "," + b);
            a = a + b;
            b = a - b;
            a = a - b;
            Console.WriteLine("After Swapping :" + a + "," + b);

No comments:

Post a Comment