Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 1.62 KB

iteration-statements-cpp.md

File metadata and controls

27 lines (20 loc) · 1.62 KB
descriptiontitlems.datehelpviewer_keywordsms.assetid
Learn more about: Iteration Statements (C++)
Iteration Statements (C++)
11/04/2016
iteration statements
loop structures, iteration statements
bf6d75f7-ead2-426a-9c47-33847f59b8c7

Iteration Statements (C++)

Iteration statements cause statements (or compound statements) to be executed zero or more times, subject to some loop-termination criteria. When these statements are compound statements, they are executed in order, except when either the break statement or the continue statement is encountered.

C++ provides four iteration statements — while, do, for, and range-based for. Each of these iterates until its termination expression evaluates to zero (false), or until loop termination is forced with a break statement. The following table summarizes these statements and their actions; each is discussed in detail in the sections that follow.

Iteration Statements

StatementEvaluated AtInitializationIncrement
whileTop of loopNoNo
doBottom of loopNoNo
forTop of loopYesYes
range-based forTop of loopYesYes

The statement part of an iteration statement cannot be a declaration. However, it can be a compound statement containing a declaration.

See also

Overview of C++ Statements

close