The for loop executes a block of code repeatedly until the specified expression evaluates to false. You can define a for loop as follows.

for ([initializer(s)]; [condition]; [iterator]) 
{
   // code to repeat goes here
}

The [initializer(s)] portion is used to initialize a value, or values, as a counter for the loop. On each iteration, the loop checks that the value of the counter is within the range to execute the for loop, specified 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 for incrementing the loop counter.

The following code example shows how to use a for loop to execute a code block 10 times.

for Loop
for (int i = 0 ; i < 10; i++) 
{
    // Code to execute.
}
In this example, i = 0; is the initializer, i < 10; is the condition, and i++ is the iterator. 


This contents come from edx : Introduction to C++

저작자 표시
신고

'Tips > C++ Eng' 카테고리의 다른 글

Introducing Classes  (0) 2015.11.28
Storage classes and Scope  (0) 2015.11.23
Introducing the for Loop  (0) 2015.11.04
The Conditional (Ternary : 3중 조건문)  (0) 2015.11.04
switch Statments  (0) 2015.11.04
Introducing Operators  (0) 2015.11.01

WRITTEN BY
Profile
비타오백
Enjoy your stage!

받은 트랙백이 없고 , 댓글이 없습니다.
secret