Professional Documents
Culture Documents
The for loop executes a block of code repeatedly until the specified
Module 1
expression evaluates to false. You can define a for loop as follows.
Introducing
C++
for ([initializer(s)]; [condition]; [iterator])
{
Module 2 Data
// code to repeat goes here
Types in C++
}
Module 3
The [initializer(s)] portion is used to initialize a value, or values,
Control
as a counter for the loop. On each iteration, the loop checks that the
Statements
value of the counter is within the range to execute the for loop, specified
C++ Operators in the [condition] portion., and if so, execute the body of the loop. At
then end of each loop iteration, the [iterator] section is responsible
Decision
Statements
for incrementing the loop counter.
Self-Check
The following code example shows how to use a for loop to execute a
Repetition
Statements code block 10 times.
Self-Check
https://courses.edx.org/courses/coursev1:Microsoft+DEV210x+2T2017/courseware/bfc4cb492f3241a3891a98587ddfb849/d4c37651971a4651809b018ecd4f99b2/ 1/2
4/23/2017 for Loops | Repetition Statements | DEV210x Courseware | edX
© 2012-2017 edX Inc. All rights reserved except where noted. EdX, Open edX and the edX and Open EdX logos
are registered trademarks or trademarks of edX Inc.
https://courses.edx.org/courses/coursev1:Microsoft+DEV210x+2T2017/courseware/bfc4cb492f3241a3891a98587ddfb849/d4c37651971a4651809b018ecd4f99b2/ 2/2