Program Flow |
|
if / elseif (expression) statement-1 [else statement-2] If expression evaluates true statement-1 is executed, otherwise statement-2. The else-part is optional. switch / case / default / breakswitch (expression-0) { case expression-1: [statements] [case expression-2: [statements]] ... [case expression-N: [statements]] [default: statements] } expression-0 is compared with expression-1 ... expression-N. As soon as a match is found, all subsequent statements within the switch block are executed. The statements after default are executed if none of the previous expressions was matched. Within the statements, break is used to leave the switch block premature. Note that unlike C, expression-1 ... expression-N don't have to be constants. while / break / continuewhile (expression) statement While expression evaluates true statement is executed. (The check is done before statement is executed). The loop may be left premature by break. With continue the rest of statement is skipped and the loop continues with the next expression check. do / while / break / continuedo statement while (expression) statement is repeated until expression becomes false. (The check is done after statement execution). The loop may be left premature by break. With continue the rest of statement is skipped and the loop continues with the nextexpression check. for / break / continuefor ([expression-1]; [expression-2]; [expression-3]) statement expression-1 is executed once as initializer. As long asexpression-2 evaluates true statement and expression-3 are executed in sequence. If expression-2 is not present, it is taken as permanently true. The loop may be left premature by break. Withcontinue the rest of statement is skipped and the loop continues with the next expression-3 followed by the expression-2 check. | ||||||||
Copyright © IBK Landquart | Last revised by Peter Koch, 24.02.00 | << Back Top Next >> |