Sorting Numbers
One of the most common tasks for a computer is sorting, so we'll develop a program to sort integers. We'll take a black box approach and think in terms of input and output. The overall plan, shown in Figure 13.2, is pretty simple.
Figure 13.2. Sorting program: a black box view.
At this point, the program is still too vaguely defined for us to begin writing code. The next step is to identify the main tasks that the program must do to accomplish our goals. We can break the example down to three such tasks:
Read the numbers.
Sort them.
Print the sorted numbers.
Figure 13.3 shows this breakdown as we descend from the top level of ...
Get C Primer Plus®, Third Edition 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.