This is the simple and logic building program related to array. The program will sort all the numbers in a given array in ascending order.
Source Code
using System;
using System.Collections.Generic;
using System.Text;
namespace assad
{
class sortArrays
{
static void Main(string[] args)
{
welcomeScrean();
int[] array = new int[10];
Random rnd = new Random();
Console.WriteLine("Random Numbers");
for ( int i = 0 ; i < array.Length ; i++ ) {
array[i] = rnd.Next(0, 101); // generates a random array
Console.WriteLine(array[i]);
}
Array.Sort(array); // sorts array
Console.WriteLine("Sorted Numbers");
for ( int i = 0 ; i < array.Length ; i++ ) {
Console.WriteLine(array[i]);
}
int ab = Console.Read();
}
private static void welcomeScrean()
{
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("\t*******************************************************" + "\n"
+ "\t*******************************************************" + "\n"
+ "\t** Sort **" + "\n"
+ "\t** Numbers Array **" + "\n"
+ "\t** Program **" + "\n"
+ "\t*******************************************************" + "\n"
+ "\t*******************************************************\n\n\n\n");
}
}
}
0 comments:
Post a Comment