Saturday 24 February 2018

How to swap two Number with out using 3 rd variable using C# programming Code?

Code:  Using System;
            class program
            {
             public static void Main(strings args[])
              console.write("Enter a value : ");
              int a=Toint32(console.readline());
              Console.write("Enter b value : ");
              int b=Toint32(Console.ReadLine());
              a=a+b;   //      a=5 ; b=10;     a=15; 
              b=a-b;   //       b=15-10;         b=5;
              a=a-b;  //        a=15-5;            a=10;
             
             Console.WriteLine(" a value is :" + a);
             Console.WriteLine("b value is:"+b);

            
            }

No comments:

Post a Comment