EasyManua.ls Logo

Casio FX-890P

Casio FX-890P
126 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
115
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.

Table of Contents

Related product manuals