Write a C# program to swap two numbers without using third variable.

 


using System;

public class SwapNumbers
{
    public static void Main(string[] args)
    {
        int x = 10;
        int y = 20;

        // Swap x and y without using a third variable.
        x = x + y;
        y = x - y;
        x = x - y;

        Console.WriteLine("x = " + x);
        Console.WriteLine("y = " + y);
    }
}
Write a C# program to swap two numbers without using third variable. Write a C# program to swap two numbers without using third variable. Reviewed by Bhaumik Patel on 8:06 PM Rating: 5