Chapter 7: Program Control Structures
If all of our code was simply executed in sequence, our programs would always do the same thing, no matter what data we provided them with. We must be able to control the path through the program so that some part of the code executes at the designated time, and other parts at other times, depending on the values provided by the data. For instance, only if it is cold outside do you put on warm clothes, not always. The same thing applies to our code. When things are a certain way, we want something to happen.
In a way, we can say that we, by this, will introduce some sort of intelligence, or at least some decision-making capabilities into our code. If things are this way, do this, if not, do that.
In this chapter, you will learn the following topics:
- Controlling the execution path of the program
- Making decisions with the help of
if
statements - Selecting one out of many options with
switch
statements - Repeating code execution...