Statements
{
- statement
;
- statement
;
- statement
;
}
if (
expression)
statementA;
[ else
statementB;
]
- Executes statementA if the expression is true,
otherwise executes statementB. In nested if statements, the
else
refers to the nearest if
which is not already associated with an else
.
switch (
expression)
{
-
case
constantA:
- statements executed if expression equals
constantA
break;
case
constantB:
case
constantC:
- statements executed if expression equals constantB
or constantC
break;
- [
default:
- statements executed if expression doesn't equal any constant
listed ]
}
for (
initialisation;
condition;
increment)
statement;
- Execute the initialisation statement (e.g. assigning an
initial value to the loop counter). While the condition expression is
true (e.g. test for the loop counter having reached its final value) execute
the statement then the increment statement (e.g. to increment the
loop counter).
while (
expression)
statement;
- Execute statement repeatedly while the expression is
true: may never execute if it's false on entry to the loop.
do
statement while (
expression);
- Execute statement repeatedly while the expression is
true: always executes at least once.
return
[expression];
- Terminate execution of the current function, and return the value of
the expression
goto
label
- |
- label
:
- Transfer execution to the labelled statement, which must be in the
same function.
break;
- Terminate execution of the smallest enclosing loop or switch
statement.
continue;
- Forces the next iteration of the smallest enclosing loop to
immediately start execution.
- expression
;
- See the next section.