Sorting of Number using loop in C#

public static void Main(string[] args)
{
int[] x = { 20, 10, 50, 46, 26, 87, 25, 5, 97, 24 };

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

{

for (int j = i; j < x.Length; j++)

{

if (x[i] > x[j])
{
int temp;
temp = x[i];
x[i] = x[j];
x[j] = temp;
}
}
}
for (int i = 0; i < x.Length; i++)
{
Console.WriteLine($”{x[i]}”);
}
Console.ReadKey();

}

Leave a Reply

Your email address will not be published. Required fields are marked *

Protected with IP Blacklist CloudIP Blacklist Cloud

This site uses Akismet to reduce spam. Learn how your comment data is processed.