The for statement is similar to the while statement, but more specific. It looks like this:
The initialization argument declares and initializes the counter variable:
The counterModification is usually...
Example
- Code:
for(initialization, condition, counterModification)
{
// repeat until condition is false
}
- Code:
for (;;)
{
// body
}
- Code:
while(1)
{
// body
}
The initialization argument declares and initializes the counter variable:
- Code:
i = 0
- Code:
i < max
The counterModification is usually...
- Code:
i++
- Code:
i = i + 1
- Code:
i += 1
Example
- Code:
for(counter = 0, counter < 10, counter++)
{
self iPrintlnBold(counter);
wait 1;
}
- Code:
for(counter = 10, counter > 0, counter -= 2)
{
self iPrintlnBold(counter);
wait 1;
}