Reference no: EM132211449
Question: Write a program that reads its input into an array and then uses selection sort to sort the array. In selection sort, we first find the smallest element in the array and exchange it with the first array element's value; then we find the next smallest element in the array and exchange it with the second array element's value; and so on, until the array is sorted.
Have your program include 4 functions, besides main, which perform the following functions:
1. Read in an undetermined number of array elements.
2. Print the array elements (call this function both before and after the elements are sorted).
3. Sort the array elements.
4. Swap two elements of an array (this function will be called by your sort function).
Do not use any jump statement, e.g., the break statement.
Declare the maximum array size as a constant MAXSIZE with a value of 10.
Run your program with the following set of input:
1. 5 12 -7 3 0
2. 1 2 3 4 5 7 6
3. Some input that will trigger each of your errors checks, what happens when you enter more values than MAXSIZE or when invalid (nonnumeric) data is entered. Flush the invalid data and continue reading until EOF or the array is full. Print appropriate error message for invalid character data and for too many values. Data items should still be sorted, even if invalid character data is encountered or too many values are entered.