Algoritma-4

Repetition/Looping Operation

Repetition/looping operation:

  • For

for(exp1; exp2; exp3) statement; ||

for(exp1; exp2; exp3){statement1; statement2; }

exp1 & exp3=bisa berisi banyak menggunakan koma

  1. exp1 = initialization
  2. exp2 = conditional
  3. exp3 = increment or decrement

exp1, exp2, exp3 = optional

  • While <minimal 0>

while(exp) statement;  ||

while(exp){statement1; statement2; }

exp = boolean expression

True = not zero -> statement executed

False = zero

  • Do-While <minimal 1>

do{statement; }while(exp);

True = keep executing

False = stop executing

 

Leave a Reply

Your email address will not be published. Required fields are marked *