1 / 13

Praktikum Bahasa C

Praktikum Bahasa C. Struktur Kendali. Bentuk Struktur Kendali. Struktur IF Struktur IF – Else Struktur Switch. Flowchart Struktur IF. Pernyataan_A. Kondisi. true. Pernyataan_C. i f ( kondisi ) {true_statement;}. false. Pernyataan_B. IF ( Syarat Tunggal - Code). # include <stdio.h>

sumi
Download Presentation

Praktikum Bahasa C

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Praktikum Bahasa C Struktur Kendali

  2. Bentuk Struktur Kendali • Struktur IF • Struktur IF – Else • Struktur Switch

  3. Flowchart Struktur IF Pernyataan_A Kondisi true Pernyataan_C if ( kondisi ) {true_statement;} false Pernyataan_B

  4. IF ( Syarat Tunggal - Code) # include <stdio.h> #include <stdlib.h> int main () { int nilai; printf("Masukkan Nilai : "); scanf("%d", &nilai); if (nilai >= 65) {printf("Selamat Anda Lulus");} getch(); }

  5. IF ( Syarat Jamak - Code) # include <stdio.h> #include <stdlib.h> int main () { int nilai, kehadiran; printf("Masukkan Nilai : "); scanf("%d", &nilai); printf("Masukkan Kehadiran : "); scanf("%d", &kehadiran); if (nilai >= 65 && kehadiran >= 10) {printf("Selamat Anda Lulus");} getch(); }

  6. Flowchart Struktur IF if ( kondisi ) {true_statement;} else {false_statement;} Pernyataan_A Kondisi true false Pernyataan_C Pernyataan_C Pernyataan_B

  7. IF - Else ( Tunggal - Code) # include <stdio.h> #include <stdlib.h> int main () { int nilai, kehadiran; printf("Masukkan Nilai : "); scanf("%d", &nilai); printf("Masukkan Kehadiran : "); scanf("%d", &kehadiran); if (nilai >= 65 && kehadiran >= 10) {printf("Selamat Anda Lulus");} else {printf("Sayang Sekali Anda Belum Beruntung");} getch(); }

  8. Strultur IF - Else ( Bersarang ) if ( kondisi_1) { if ( kondisi_2 ) true_statement_2; else false_statement_2; } else { false_statement_1; }

  9. IF - Else ( Bersarang - Code) if (nilai >= 65) { if (kehadiran >= 10) { printf("Selamat Anda Lulus"); } else { printf("Karena Malas Hadir, Anda Tidak Lulus"); } } else { printf("Maaf Sekali, Anda Tidak Lulus"); } getch(); } # include <stdio.h> #include <stdlib.h> int main () { int nilai, kehadiran; printf("Masukkan Nilai : "); scanf("%d", &nilai); printf("Masukkan Kehadiran : "); scanf("%d", &kehadiran);

  10. Struktur SWITCH switch (pilihan) { case pilihan1 : {aksi_1; break;} case pilihan2 : {aksi_2; break;} case pilihan3 : {aksi_3; break;} default : {aksi_default; break;} }

  11. Flowchart Struktur SWITCH pilihan pilihan pilihan 4 pilihan 3 pilihan 1 pilihan 2 aksi 1 aksi 2 aksi 3 aksi 4 pernyataan berikutnya

  12. Struktur SWITCH ( code ) # include <stdio.h> #include <stdlib.h> int main () { int bulan; printf("Masukkan Bulan (dalam angka) : "); scanf("%d", &bulan); switch (bulan) { case 1 : {printf("Bulan Januari"); break;} case 2 : {printf("Bulan Februari"); break;} case 3 : {printf("Bulan Maret"); break;} case 4 : {printf("Bulan April"); break;} case 5 : {printf("Bulan Mei"); break;} case 6 : {printf("Bulan Juni"); break;} case 7 : {printf("Bulan Juli"); break;} case 8 : {printf("Bulan Agustus"); break;} case 9 : {printf("Bulan September"); break;} case 10 : {printf("Bulan Oktober"); break;} case 11 : {printf("Bulan Novemver"); break;} case 12 : {printf("Bulan Desember"); break;} default : {printf("Masukkan Angka dari 1 s.d. 12"); break;} } getch(); }

  13. Q & A ?

More Related