5.11. Wrap-Up

In this chapter, we completed our introduction to C++'s control statements, which enable you to control the flow of execution in functions. Chapter 4 discussed the if, if...else and while statements. The current chapter demonstrated C++'s remaining control statements—for, do...while and switch. We have shown that any algorithm can be developed using combinations of the sequence structure (i.e., statements listed in the order in which they should execute), the three types of selection statements—if, if...else and switch—and the three types of repetition statements—while, do...while and for. In this chapter and Chapter 4, we have discussed how you can combine these building blocks to utilize proven program construction and problem-solving techniques. This chapter also introduced C++'s 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 3, we introduced C++ programming with the basic concepts of classes, objects and member functions. Chapter 4 and this chapter provided a thorough introduction to the control statements that you typically use to specify program logic in functions. In Chapter 6, we examine functions in greater depth.