1 / 13

ALGORITMA & PEMROGRAMAN

ALGORITMA & PEMROGRAMAN. Tegal , 2 DESEMBER 2011. Khairul Fahmi fahmikhairul@gmail.com. STRUKTUR DASAR PEMILIHAN. 1. SATU KASUS if kondisi then begin aksi ; end; 2. DUA KASUS if kondisi then begin aksi 1 end; else

dong
Download Presentation

ALGORITMA & PEMROGRAMAN

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. ALGORITMA & PEMROGRAMAN Tegal, 2 DESEMBER 2011 KhairulFahmi fahmikhairul@gmail.com

  2. STRUKTUR DASAR PEMILIHAN 1. SATU KASUS if kondisithen begin aksi; end; 2. DUA KASUS if kondisi then begin aksi 1 end; else begin aksi 2 end;

  3. STRUKTUR DASAR PEMILIHAN 3. JAMAK if kondisi 1 then begin aksi 1 end else if kondisi 2 then begin aksi 2 end else if kondisi n then begin aksi n end

  4. STRUKTUR DASAR PEMILIHAN 3. JAMAK MENGGUNAKAN CASE case ekspresi of kondisi1 : begin aksi1 end; . . . kondisi n : begin aksin end; end;

  5. CONTOH PROGRAM SATU KASUS AlgoritmaMenentukanapakahsuatubilangangenap Masukkansebuahbilangansembarang Bagibilangantersebutdengan 2 Hitungsisahasilbagipadalangkah 2 Bilasisahasilbagisamadengan0 makabilanganituadalahbilangangenap

  6. CONTOH PROGRAM Program Bil_genap Var bil : integer; Begin Write(‘Ketikkanbilangansembarang’); Readln(bil); if bil mod 2 =0 then begin Write(‘Bilangangenap’); end; readln; End.

  7. CONTOH PROGRAM Program Bil_genap Var bil : integer; Begin Write(‘Ketikkanbilangansembarang’); Readln(bil); case bil mod 2 of 0 : begin Write(‘Bilangangenap’); end; end; readln; End.

  8. CONTOH PROGRAM DUA KASUS AlgoritmaMenentukanapakahsuatubilanganganjilataugenap Masukkansebuahbilangansembarang Bagibilangantersebutdengan 2 Hitungsisahasilbagipadalangkah 2 Bilasisahasilbagisamadengan0 makabilanganituadalahbilangangenap tetapibilasisahasilbagisamadengan 1 makabilanganituadalahbilanganganjil

  9. CONTOH PROGRAM Program Bil_genap_ganjil Var bil : integer; Begin Write(‘Ketikkanbilangansembarang’); Readln(bil); if bil mod 2 =0 then begin Write(‘Bilangangenap’); end else begin Write(‘Bilanganganjil’); end; readln; End.

  10. CONTOH PROGRAM Program Bil_genap Var bil : integer; Begin Write(‘Ketikkanbilangansembarang’); Readln(bil); case bil mod 2 of 0 : begin Write(‘Bilangangenap’); end; 1 : begin Write(‘Bilangangenap’); end; end; readln; End.

  11. CONTOH PROGRAM TIGA KASUS AlgoritmaMenentukanapakahsuatubilanganbulatpositif, negatifataunol Masukkansebuahbilangansembarang Jikabilanganlebihbesarnolmakabilanganbulatpositif Tetapijikabilangankurangdarinolmakabilanganbulatnegatif Tetapijikabilangansamadengennolmakabilanganbulat nol.

  12. CONTOH PROGRAM Program Bil_positif_negatif Var bil : integer; Begin Write(‘Ketikkanbilangansembarang’); Readln(bil); if bil> 0 then begin Write(‘Bilanganpositif’); end else if bil < 0 then begin Write(‘Bilangannegatif’); end; else if bil= 0 then begin Write(‘Bilangannol’); end; readln; End.

  13. TerimaKasih KhairulFahmi fahmikhairul@gmail.com 085718295334

More Related