Selasa, 18 Desember 2018

LOOPING / REPETITION



Repetisi dalam bahasa inggris sering disebut loops, biasanya digunakan untuk mengulang kode yang sama berkali-kali. Jumlah repetisinya itu beragam sesuai yang diinginkan, biasanya berisi ekspresi true/false.
Ada 3 variasi looping : while, do while, dan for.

While Looping : Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body.
Ex : while(...){
      ......;
}

Do While Looping : It is more like a while statement, except that it tests the condition at the end of the loop body. 
Ex : do{
     ......;
}while(....);

For Looping : Executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.
Ex : for(...;...;...){
            ........;
}

Tidak ada komentar:

Posting Komentar