Selection Sort

This function sorts an array using the algorithm known as selection sort. The array is composed of elements of type int, holding a single integer. Because C has no way to determine the number of elements in an array, this is passed as a second argument to the function.

Selection sort uses two nested loops. The first time through the outer loop, the inner loop finds the element in the array that has the lowest number. It then swaps that element with the element in the first position in the array, so that the first element now has the lowest number in it. The outer loop then iterates again, finding the next lowest number in the array ...

Get Find the Bug A Book of Incorrect Programs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.