How to Swap Two Numbers in C#? Example.

class SwapTwoNumbers
    {
        public static void Swap()
        {
            int a, b;
            a = 5; b = 10;
            b = b - a;
            a = a + b;
            Console.WriteLine("After swaping value of a : " + a);
            Console.WriteLine("After swaping value of b : " + b);
            Console.ReadLine();
        }
    }
Share:

No comments:

Post a Comment

Friday, 28 June 2019

How to Swap Two Numbers in C#? Example.

class SwapTwoNumbers
    {
        public static void Swap()
        {
            int a, b;
            a = 5; b = 10;
            b = b - a;
            a = a + b;
            Console.WriteLine("After swaping value of a : " + a);
            Console.WriteLine("After swaping value of b : " + b);
            Console.ReadLine();
        }
    }

No comments:

Post a Comment

Popular

Total Pageviews

Archive