Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

1 Praktikum C Programming Perulangan / Loop

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

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

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

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

6 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; }

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

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

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

10 Latihan


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

Similar presentations


Ads by Google