Showing posts with label swap of two numbers in c#. Show all posts
Showing posts with label swap of two numbers in c#. Show all posts

Sunday, November 5, 2017

Swap of Two Numbers in C#

Here is a simple program that I wrote using C# as my programming language to demonstrate how to use methods in C#. I will swap the arrangement of two numbers.

I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.




Sample Program Output


Program Listing

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

namespace ConsoleApplication1
{
    public class Swap_Number
    {

        public static void Swap(ref int x, ref int y)
        {
            int swap;

            swap = x;
            x = y;
            y = swap;
        }

        public static void Main()
        {
            int x = 10;
            int y = 15;

            Console.WriteLine("Swap Two Numbers in C# ");
            Console.Write("\n");
            Console.WriteLine("By Mr. Jake R. Pomperada, MAED-IT ");
            Console.Write("\n\n");
            Console.WriteLine("Before  ");
            Console.Write("\n\n");
            Console.WriteLine("x: {0} , y: {1}", x, y);
            Swap(ref x, ref y);
            Console.Write("\n\n");
            Console.WriteLine("After  ");
            Console.Write("\n\n");
            Console.WriteLine("x: {0} , y: {1}", x, y);
            Console.Write("\n\n");
            Console.Write("\t Thank You For Using This Software.");
            Console.ReadKey();
        }
    }
}