How it works...

You will be asked to specify how many numbers you require to be sorted. Suppose we want to sort 8 numbers; the value 8 entered by the user will be assigned to the len variable. A for loop is executed enabling us to enter the number to be sorted. The values we enter will be assigned to the arr array as shown in Figure 9.21.

Two variables, lindex and uindex, are initialized to represent the desired first and last index of the array, that is 0 and 7, respectively. The lindex and uindex locations are supposed to keep the smallest and largest values in the array. The values of lindex and uindex, that is, 0 and 7, will be pushed to the stack. In the pushstk1 function, the value of the top index, whose default value is -1, is incremented ...

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.