Chapter 4. Control structures
This chapter covers
Conditional statements allow your program to make decisions given rules and facts, as you now know from chapter 3. If your programs could use these decisions to jump around within their source code and execute different sections, they could become vastly more powerful. With such commands, you could create whole new classes of programs and games. You’d be able to write your own programs like the GUESS guessing game in chapter 1 that we touched on briefly again in chapters 2 and 3. With loop and jump commands, you’d be able to write a science program that simulates the solar system, repeatedly stepping the planets along their orbits around the sun until told to stop. A math program could offer a menu of possible types of equations it could help you solve, and it could use jumps to go to different parts of the program to solve that equation depending on which option the user chooses.