How it works...

We will start by defining a macro, max, of value 20. You can always increase the value of max as required. Then, we will define an array, arr, of size max, that is, of size 20. You will be asked how many values you want to sort. Assuming that you want to sort seven elements, the value you entered will be assigned to the len variable. You will be prompted to enter the values to be sorted, which will then be assigned to the arr array. The seven values to be sorted in the arr array might appear as follows:

Figure 9.7

Now, we will run two nested for loops: the outer for loop will execute from len-2, that is, from value 5 to 1 in ...

Get Practical C Programming 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.