2024年6月14日发(作者:)
/* While Loops */
while (conditional-expression) {
nested-statements
}
/* For Loops */
for (initialization; conditional-expression; increment) {
nested-statements
}
/* Do-While Loops */
do {
nested-statements
} while (conditional-expression);
Conditional Execution And Selection
If Statements
If-Else Statements
Switch Statements
-conditional execution of a single statement
-conditional selection among two statements
-conditional selection among several statements
Extended If Statements-conditional selection among several statements
/* If Statements */
if (conditional-expression) {
then-clause
}
/* If-Else Statements */
if (conditional-expression) {
then-clause
}
else {
else-clause
}
/* Switch Statements */
switch (control-expression) {
case constant-expression-1:
statements-1
.
.
.
case constant-expression-n:
statements-n
default:
default-statements
}
/* Extended If Statements */
if (conditional-expression-1) {
statements-1
}
else if (conditional-expression-1) {
statements-1
.
.
.
}
else if (conditional-expression-n) {
statements-n
}
else {
default-statements
}
Special Control Statements
Return Statements
Break Statements
/* Return Statements */
return;
return expression;
/* Continue Statements */
continue;
/* Break Statements */
break;
实例略
-return values from and terminate functions
-exit a loop or switch statement
Continue Statements-skip the remaining statements in an iteration of a loop


发布评论