C++

Sort an array in Ascending Order in C++1 min read

Write a program that asks the user to type 10 integers that will be stored in an array. The program must sort the array in ascending order and must display the array.
Suggested algorithm:
We look for the index of the smallest element among the indices from 0 to 9 and we exchange this element with t [0].
We look for the index of the smallest element among the indices from 1 to 9 and we exchange this element with t [1].
We look for the index of the smallest element among the indices from 2 to 9 and we exchange this element with t [2].
We look for the index of the smallest element among the indices of 8 to 9 and we exchange this element with t [8].

 

The purpose of this exercise is to check the following technical points:
Simple use of arrays.
A simple algorithm on an array: sorting an array.

Here is the source file:




 

Output:

Leave a Comment