Introduction to the Program Control Structures

Get an overview of what will be covered in this chapter.

We'll cover the following

Overview

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, we don’t put on warm clothes all the time, but only if it’s cold outside. 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, by doing this, we’ll 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.

Get hands-on with 1200+ tech skills courses.