Program Control: Repetition
-Repetition is the repetition of one or more instruction(s) for a certain period of time.
-The number of repetition can be predefined or post defined.
-Repetition/looping operation: for, while, do-while.
-The format of a For instruction is:
for(exp1; exp2; exp3){
statement1;
statement2;
…….
}
-The format of a While instruction is:
while(exp){
statement1;
statement2;
…..
}
-The format of a Do-While instruction is:
do{
< statements >;
} while(exp);
-In while operation, statement block of
statements may never be executed at all if
exp value is false
-In do-while on the other hand statement block
of statements will be executed min once
-break:
–ending
loop (for, while and do-while)
–end
the switch
operation
-continue:
-skip all the rest of statements (subsequent to
the skip statement) inside a repetition, and continue normally to the next loop