Casio FX-890P Owner's Manual page 115

Casio personal computer owner's manual
Table of Contents

Advertisement

for()
PURPOSE: Executes repeatedly a statement as long as the specified condition is
true (not zero).
FORMAT:
for (expression 1; condition; expression 2) statement
PARAMETERS:
1. expression 1 sets initial state.
2. condition allows the loop to repeat.
3. expression 2 is executed after the statement.
EXPLANATION:
1. First, expression 1 is executed on first pass only (initialization).
2. Then, condition is evaluated. If true (not 0), the statement is executed. If false,
loop ends.
3. After execution of the statement, expression 2 is executed, and execution
loops back to condition evaluation.
4. Note that the any "for" loop could be written:
for (expression 1; condition; {statement; expression 2});
Nevertheless, commonly accepted programming practice is to reserve the
parenthesis after the "for" statement for loop control, putting all other
statements after.
SAMPLE PROGRAM:
/* For example */
/* #include <stdio.h> */
main(){
char ch;
For (ch='0'; ch<='Z'; ch++){
printf("Char(%c) = Hex(0x%x)¥n",ch,ch);
getchar(); /* waits for return key */
}
}
SEE: do while(), while(), break, continue
break
PURPOSE: exits from a "do while", "while" of "for" loop.
FORMAT:
break;
EXPLANATION:
1. Execution of a "break" is the loop statement, will exit the loop whatever the
loop condition status is.
2. Any statement following the "break" within the loop is not executed.
SEE: do while(), while(), switch() case, continue
continue
PURPOSE: Returns execution to the beginning of a "do while", "while" of "for" loop.
FORMAT:
break;
EXPLANATION:
1. Any statement following the "continue" within the loop is not executed.
2. condition for loop is evaluated, and a new loop is executed if condition is true.
115

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Z-1grZ-1

Table of Contents