Friday, 1 September 2017

c# programming tutorial to implement a Swap 2 Numbers Using Function

Program example to sum of two use to function C# Programming

Program

class Program
 {
static void swap(ref int x,ref int y)
        {
             int z = x;           
             x = y;
             y = z;
        }

static void Main(string[] args)
        {
             int a, b;
            Console.WriteLine("Number 1:");
             a = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Number 2:");
            b = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("After Swapping");
             swap(ref a,ref b);
            Console.WriteLine("Number 1: {0} , Number 2: {1}", a, b);
        }

    }  

Output


0 comments:

Post a Comment