While | Until | For |
C syntax
while (expression)
statement;
while (expression)
{
statement(s);
}
|
C syntax
do
statement;
while (expression);
do
{
statement(s);
}
while (expression);
|
C syntax
for (initialize; compare; increment)
statement;
for (initialize; compare; increment)
{
statement(s);
}
|
General - logically controlled loop |
General - logically controlled loop |
Restricted - counter controlled loop |
Comparison at top | Comparison at bottom |
Comparison at top and is part of the syntax of the loop |
Executes 0 or more | Executes 1 or more |
Executes 0 or more |
1 or more Loop Control Variables | 1 or more Loop Control
Variables | ONE Loop Control Variable |
Loop Control Variables can be any data type |
Loop Control Variables can be any data type |
Loop Contral Variable is of an integral type (integer, character) |
One or more compound comparisons |
One or more compound comparisons |
One comparison - either <= or >= depending on whether counting up
or down |
Any legal statement may be used to change the value of the loop
control variable | Any legal statement may be used to change the loop
control varialbe | The loop control variable is incremented or
decremented by a fixed amount as part of the syntax of the loop |
Every until loop and every for loop can be written as a while |
Every while loop and every for loop can be written as an until |
Only some while loops and until loops can be written as for loops |