|
5.2 Control structures
A sequence of commands surrounded by curly brackets ({ and
} ) is a so-called block. Blocks are used in SINGULAR in
order to define procedures and to collect commands belonging to
if , else , for and while statements and to the
example part in libraries. Even if
the sequence of statements consists of only a single command it has to be
surrounded by curly brackets!
Variables which are defined inside a block
are not local to that block. Note that there need not be an ending semicolon at
the end of the block.
Example:
| if ( i>j )
{
// This is the block
int temp;
temp=i;
i=j;
j=temp;
kill temp;
}
|
|