CONTENTS
Section 6.1 Simple Statements
Section 6.2 Declaration Statements
Section 6.3 Compound Statements (Blocks)
Section 6.4 Statement Scope
Section 6.5 The if Statement
Section 6.6 The switch Statement
Section 6.7 The while Statement
Section 6.8 The for Loop Statement
Section 6.9 The do while Statement
Section 6.10 The break Statement
Section 6.11 The continue Statement
Section 6.12 The goto Statement
Section 6.13 try Blocks and Exception Handling
Section 6.14 Using the Preprocessor for Debugging
Statements are analogous to sentences in a natural language. In C++ there are simple statements that execute a single task and compound statements that consist of a block of statements that execute as a unit. Like most languages, C++ provides statements for conditional execution and loops that repeatedly execute the same body of code. This chapter looks in detail at the statements supported by C++.
flow-of-control statements that allow statements to be executed conditionally or repeatedly. The if and switch statements support conditional execution. The for, while, and do while statements support repetitive execution. These latter statements are often referred to as loops or iteration statements.