Controlling the execution path
In Chapter 5, Sequence – The Basic Building Block of a Computer Program, we learned that the code within a program is executed in sequence.
A sequence is one of the three basic logical structures we have in programming. So, in this chapter, we will cover the other two, selection and iteration.
Selection statements
There are situations when we only want to execute some code if a condition is met. For example, if you recall our application from Chapter 5, Sequence - The Basic Building Block of a Computer Program which turned on the outdoor light, we had a condition that said if our phone detected that we were within a given range from our house, it should send a signal to the home computer. To refresh your memory, let's take a look at some images you have seen before. Figure 7.1 was used to illustrate the action of us entering the range: