"coinjo" <co****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I have some trouble understanding the for loop. Can any one explain the
basic structure and functionality of a for loop to me?
for(init; condition; iteration)
{
/* body */
}
X:
1. expression 'init' is evaluated
2. expression 'condition' is evaluated; if
it evaluates to false, execution flow
continues at X: ; if it evaluates to true,
statements within 'body' are executed; then ...
3. expression 'iteration' is evaluated
4. Go to 2.
Note: Each of 'init', 'condition', and 'iteration',
are optional (but the semicolons are not).
Example:
for(int i = 0; i < 10; ++i)
{
foo();
}
Function foo() will be called exactly ten times, then
execution flow continues after the closing brace ( } )
Which C++ book(s) are you reading that don't explain
this very basic programming element?
-Mike