Home Online Manual
Back: exportto
Forward: if
FastBack: Functions
FastForward: System variables
Up: Control structures
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

5.2.8 for

for ( init_command; boolean_expression; iterate_commands) block
repetitive, conditional execution of a command block.
The command init_command is executed first. Then boolean_expression is evaluated. If its value is TRUE the block is executed, otherwise the for statement is complete. After each execution of the block, the command iterate_command is executed and boolean_expression is evaluated. This is repeated until boolean_expression evaluates to FALSE.
The command break; leaves the innermost for construct.
// sum of 1 to 10:
int s=0;
for (int i=1; i<=10; i=i+1)
==> 55
See Control structures; boolean expressions; break; continue; if; while.