Search This Blog

Monday 14 December 2015

How to arrange numbers numerically









Hello guys you can arrange numbers numerically from an array using bubble sort method.



Its Simple and easy. Just Watch the video and view the codes below









namespace Bubble_Sort

    {

    class Program

        {

        static void Main(string[] args)

            {

            int[] save = { 2, 1, 6, 7, 8, 9 };

            int hold;

            for (int i = 0; i < save.Length; i++)

                {

                for (int j = 0; j < save.Length; j++)

                    {

                    if (save[i]<save[j])

                        {

                        hold = save[i];

                        save[i] = save[j];

                        save[j] = hold;

                        }

                    }

                }

            foreach (var item in save)

                {

                Console.Write(item+"\t");

                //Displays the arranged numbers

                }

            Console.ReadLine();

            }

        }

    }



Thanks for watching, visit csharpprogrammingisfun.blogspot.com

No comments:

Post a Comment