Answer:
Explanation:
Since no programming language is stated, I'll use Microsoft Visual C# in answering this question.
// C# program sort an array in ascending order
using System;
class SortingArray {
int n; //number of array elements
int [] numbers; //Array declaration
public static void Main() {
n = Convert.ToInt32(Console.ReadLine());
numbers = new int[n];
for(int i = 0; i<n; I++)
{
numbers [n] = Convert.ToInt32(Console.ReadLine());
}
SortArray();
foreach(int value in numbers)
{
Console.Write(value + " ");
}
}
void SortArray()
{
int temp;
// traverse 0 to array length
for (int i = 0; i < numbers.Length - 1; i++)
// traverse i+1 to array length
for (int j = i + 1; j < numbers.Length; j++){
// compare array element with all next element
if (numbers[i] < numbers[j])
{
temp = numbers[i];
numbers[i] = numbers[j];
numbers[j] = temp;
}
}
}