We’ve now completed our introduction to control statements. This chapter demonstrated the for
, do
...while
and switch
statements. We showed that any algorithm can be developed using combinations of the sequence structure, the three types of selection statements—if
, if
...else
and switch
—and the three types of repetition statements—while
, do
...while
and for
. We discussed how you can combine these building blocks. You used the break
and continue
statements to alter a repetition statement’s flow of control. We also introduced logical operators, which enable you to use more complex conditional expressions in control statements. Finally, we examined the common errors of confusing the equality and assignment operators and provided suggestions for avoiding these errors. In Chapter 6, we examine functions in greater depth.