Chapter 5 discussed the if
, if
…else
and while
control statements. In Chapter 6, we discussed the for
, do
...while
and switch
control statements. (We’ll discuss the foreach
statement in Chapter 8.) You learned that any algorithm can be developed using combinations of sequence (i.e., statements listed in the order in which they should execute), the three selection statements—if
, if
…else
and switch
—and the four iteration statements—while
, do
…while
, for
and foreach
. You saw that the for
and do
…while
statements are simply more convenient ways to express certain types of iteration. Similarly, we showed that the switch
statement is a convenient notation for multiple selection, rather than using nested if
...else
statements. We discussed how you can combine various control statements by stacking and nesting them. We showed how to use the break
and continue
statements to alter the flow of control in iteration statements. You learned about the logical operators, which enable you to use more complex conditional expressions in control statements. In Chapter 7, we examine methods in greater depth.