for
for ( init statement, condition expression, loop statement ) statements;
for ( start statement, condition, next statement ) { statements; }
Repeated execution of statements inside a for-loop. First, the init statement is executed and the condition expression is checked. If this expression returns true, then the statements inside the loop will be executed. The loop statement will be executed afterwards, following checking the condition expression again. If the expression is false, then loop execution has finishe.
Indirect parameter passing is disabled
3
No. | Type | Description |
---|---|---|
1 code |
statements :string |
init statement Will be executed once when the loop begins. Useful to initialize loop counters. |
2 code |
expression :string |
condition expression Will be calculated before every loop round. The statements in the loop will be executed if this value is true. |
3 code |
statements :string |
loop statement Will be calculated after every loop round and before the condition expression is checked again. |
for (a[] = 3, a[] < 15, a[]+=2)
{
print(a[],' ');
if (a[]==9) a[]++; // Increment to 10
}
3 5 7 9 12 14
Do not confuse syntax with C/C++! The 3 parameters are separated with commas and not semicolons. You are allowed to add multiple statements into the 1st and 3rd parameter where these statements are separated with semicolons."