Top
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

Syntax:
for ( init_command; boolean_expression; iterate_commands) block
Purpose:
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.
Example:
 
// sum of 1 to 10:
int s=0;
for (int i=1; i<=10; i=i+1)
{
   s=s+i;
}
s;
==> 55
See Control structures; boolean expressions; break; continue; if; while.

Top 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
            User manual for Singular version 4.3.2, 2023, generated by texi2html.