Tugas Algo
Repetition Definition:
One or more instruction repeated for
certain amount of time.
Number of repetition can be predefined
(hard-coded in program) or defined later at run time.
Repetition/looping operation:
–for
–while
–do-while
1) Repetition: For
• Infinite
Loop
Loop with no stop condition can use
“for-loop” by removing all parameters (exp1, exp2, exp3). To end the loop use break.
• Nested
Loop
Loop
in a loop. The repetition operation will start from the inner side loop.2) Repetition: While
• exp is
Boolean expression. It will result in true (not zero) or false (equal to zero).
• Statement
will be executed while the exp is
not equal to zero.
• exp evaluation is done before the
statements executed3) Repetiton: Do while
•Syntax
:
do{
< statements >;
}
while(exp);
•Keep
executing while exp is
true
•exp
evaluation done after executing the statement(s)
Comments
Post a Comment