Question: Write a function that takes an array and its size as inputs, and then sorts the elements of the array in ascending order. For example,

Write a function that takes an array and its size as inputs, and then sorts the elements of the array in ascending order. For example, if the array contains the values (12, -3, 5, 4, 7), then the array sorted in ascending order will be (-3, 4, 5, 7, 12). In order to sort the array, you must use the following algorithm: (0) Initialize i = 0; Starting at array index i, find the smallest value in the array at or after index i (i.e., any index greater than or equal to i within the proper array bounds). Swap the smallest value found in the array with the value at index i; Increment i by one; If i is less than the array size, then repeat the process starting at step (1). You must use the following function prototype: void sort(int array[], int size)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
