Tuesday, November 24, 2015

C# ASSECENDING ORDER SORTING ARRAYS VALUES

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

namespace ConsoleApplication17
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, j;
            double t;
            double[] arr = {1,1.2,0.98,1.38,0.99 };
            Console.WriteLine("Arrays Values ");
            for (i = 0; i < arr.Length; i++)
            {
                Console.Write(" "+arr[i]);
            }


            for (i = 0; i < arr.Length; i++)
            {
                for (j = i+1; j < arr.Length; j++)
                {
                    if (arr[i] > arr[j])
                    {
                        t = arr[i];
                        arr[i] = arr[j];
                        arr[j] = t;
                    }
                }
            }

            Console.WriteLine("\nSorted Arrays Values ");
            for (i = 0; i < arr.Length; i++)
            {
                Console.Write(" "+arr[i]);
            }

                Console.ReadKey();
        }
    }
}




No comments:

Post a Comment

JAC Board Computer || IIT 2025 || Introductory Information Technology || Class 10 || Practical Examination 2025

Marks Division HOE 30 Marks IT Application Report File 20 Marks Viva - Voce 10 Marks 1) Write an HTML code to generate a web p...