# Praktikum C Programming Perulangan / Loop. Bentuk Loop 1.Perintah for 2.Perintah while 3.Perintah do-while.

## Presentation on theme: "Praktikum C Programming Perulangan / Loop. Bentuk Loop 1.Perintah for 2.Perintah while 3.Perintah do-while."— Presentation transcript:

Praktikum C Programming Perulangan / Loop

Bentuk Loop 1.Perintah for 2.Perintah while 3.Perintah do-while

Perintah for #include main() { int i; for (i=0; i<5; i++) { printf(“%d“, i); } getch(); } for (inisialisasi, batas_akhir, counter) { statement; }

Perintah while #include main() { int i=0; while (i<5) { printf(“%d“, i); i++; } getch(); } inisialisasi; while (kondisi) { statement; counter; }

Perintah do-while #include main() { int i=0; do { printf(“%d“, i); i++; } while (i<5); getch(); } inisialisasi; do { statement; counter; } while (kondisi);

Nested Loop... 1 • Loop di dalam loop for (inisialisasi_1, batas_akhir_1, counter_1) { statement_loop1; for (inisialisasi_2, batas_akhir_2, counter_2) { statement_loop2; }

Nested Loop... 2 inisialisasi_1; while (kondisi_1) { statement_1; counter_1; inisialisasi_2; while (kondisi_2) { statement_2; counter_2; }

Nested Loop... 3 for (inisialisasi_1, batas_akhir_1, counter_1) { statement_loop1; inisialisasi_2; while (kondisi_2) { statement_2; counter_2; }

Bintang #include main() { int baris, kolom; for (baris=0; baris<5; baris++) { for (kolom=0; kolom<5; kolom++) { printf(“*”); } printf(“\n”); } getch(); }

Latihan

Similar presentations