Building on simple decision-making structures, Chapter 2, “Decisions, Decisions,” showed how computers can do complex and interesting things, such as play a game, repeat an operation a set number of times, and perform mathematical operations.
Critical to these operations are something called control structures—a set of keywords (if, else, while) and associated grammar—that control what the program does next. These control structures, nearly all inherited from C, include just a few simple but extremely versatile keywords. This chapter introduces two more: do-while and switch.
Remember that by controlling what the program does next, you control the program! It’s that simple.
If you’ve worked through ...