Thursday, 24 September 2015

Swapping Two Integer Number Without Using Temp/Third Variable in .NET

Swapping Two Integer Number Without Using Temp/Third Variable in .NET

Part-1 :: Swapping Two Integer Number without using Temp/Third Variable.


namespace SwappingWithoutUsingTempVariable
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 10;
            int b = 20;
            Console.WriteLine("First Number = {0} and Second Number = {1}",a ,b);
            a += b;
            b = a - b;
            a = a - b;
            Console.WriteLine("First Number = {0} and Second Number = {1}", a, b);
            Console.ReadLine();

        }
    }
}

Image-1 :- Console Application




Image - 2 :- Result




No comments:

Post a Comment

Factorial of a Number

Recently Viewed