Casio FX-890P Owner's Manual page 114

Casio personal computer owner's manual
Table of Contents

Advertisement

while()
PURPOSE: Executes repeatedly a statement as long as the specified condition is
true (not zero). .
FORMAT:
while (condition) statement
PARAMETERS:
Condition can be any variable or expression that will be considered true if not 0.
EXPLANATION:
1. The "while" loop first executes the condition. If the condition is met (true,
returning a value other than 0), the statement is executed, and execution
loops back to the "while" loop to evaluate the condition again.
2. Whenever the condition is not met (false, returning 0), execution of the "while"
loop is ended.
SAMPLE PROGRAM:
/* While example */
/* #include <stdio.h> */
main(){
char ch='0';
while (ch<='Z'){
printf("Char(%c) = Hex(0x%x)¥n",ch,ch);
getchar(); /* waits for return key */
ch++;
}
}
SEE: do while(), for(), break, continue
do while()
PURPOSE: Executes statement and carries on repeatedly as long as the specified
condition is true (not zero). .
FORMAT:
do statement while (condition);
PARAMETERS:
Condition can be any variable or expression that will be considered true if not 0.
EXPLANATION:
1. The "do" loop first executes the statement.
2. If the condition is met (true, returning a value other than 0), execution loops
back to the "do" loop to execute the statement again.
3. Whenever the condition is not met (false, returning 0), execution of the "do"
loop is ended.
SAMPLE PROGRAM:
/* Do While example */
/* #include <stdio.h> */
main(){
int gcm,x=56,y=63;
printf("¥nGCM(%d,%d) = ",x,y);
do{
gcm=x; x=y%x; y=gcm;
}while (x!=0)
printf("%d¥n",gcm);
}
114

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Z-1grZ-1

Table of Contents