Wednesday 3 January 2018

Swap Numbers Program in C#(Sharp)

                Swap Numbers Program in C#(Sharp)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace swaping2
{
    class Program
    {
        /*
          * we creating the SwapNum function.
          * creating the object obj and call the SwapNum function.
          *  passing the reference values num1 and num2;
       */

        void SwapNum(ref int x, ref int y)  
          {
              x = x + y;
              y = x - y;
              x = x - y;
            Console.WriteLine("Now First number is=>{0} Second is{1}",x,y);
            Console.ReadLine();
          }
            static void Main(string[] args)
            {
                int num1, num2;
                Program obj = new Program();
                Console.Write("enter First numbr");
                num1 = Convert.ToInt16(Console.ReadLine());
                Console.Write("enter Second numbr");
                num2 = Convert.ToInt16(Console.ReadLine());
                obj.SwapNum(ref num1, ref num2);
              

           }
     }
    
}   

No comments:

Post a Comment

😍Developer on Weekends #shorts #officememes #developermemes

😍Developer on Weekends #shorts #officememes #developermemes Welcome to the latest viral YouTube shorts meme for developers! 😍Developer on...