Repetition

nama:Raymond Filan
Nim:2201734184

Repetition

Definition
Instruction that repeated for certain amount of time and the number can be predefined 
later at run time

theres 3 repetition operator
1.for
2.while
3.do while

A.for
ex:
for(exp1; exp2; exp3) statement;

exp1 :  initialization
exp2 :  conditional
exp3 :  increment or decrement

exp1, exp2 and exp3 are optional



B.While
ex:
while (exp) statements;




a.In while operation, statement block of statements may never be executed at all if exp value is false
b.In do-while on the other hand statement block of statements will be executed min once
c.To end the repetition, can be done through several ways:
–Sentinel

–Question, should the repetition continue?

Comments