1 / 7

Dasar-Dasar Pemrograman

Dasar-Dasar Pemrograman. Struktur Percabangan IF-ELSE dan CASE-OF. CASE-OF. CASE-OF dapat berbentuk CASE-OF tunggal atau CASE-OF bersarang ( nested CASE-OF) Juga bisa berbentuk CASE-OF – ELSE. CASE-OF Tunggal. Bentuk: case(kondisi) of konstanta1 : statement1;

flower
Download Presentation

Dasar-Dasar 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. Dasar-Dasar Pemrograman Struktur Percabangan IF-ELSE dan CASE-OF

  2. CASE-OF • CASE-OF dapat berbentuk CASE-OF tunggal atau CASE-OF bersarang (nested CASE-OF) • Juga bisa berbentuk CASE-OF – ELSE.

  3. CASE-OF Tunggal • Bentuk: case(kondisi) of konstanta1 : statement1; konstanta2 : statement2; … konstantan : statementn; end;

  4. CASE-OF Tunggal Ex. uses crt; var x:char; begin clrscr; write(‘Masukkan huruf (A,B,C) : ‘);readln(x); case x of ‘A’:writeln(‘Anang’); ‘B’:writeln(‘Budi’); ‘C’:writeln(‘Cinta’); end; readln; end.

  5. CASE-OF Bersarang • Bentuk: case(kondisi) of konstanta1 : statement1; case (kondisi) of konstanta1a : statement1a; konstanta1b : statement1b; … end; … konstantan : statementn; end;

  6. CASE-OF - ELSE • Bentuk: case(kondisi) of konstanta1 : statement1; konstanta2 : statement2; … konstantan : statementn; else statement end;

  7. CASE-OF Bersarang Ex. uses crt; var status:char; ja:integer; tunj:real; begin write(‘Input Status [S/D] : ‘); readln(status); case status of ‘S’:tunj:=0; ‘D’:begin write(‘Input Jumlah Anak : ‘); readln(ja); case ja of 1..2:tunj:=ja*100000; else tunj:=((ja-2)*50000)+(2*100000); end; end; end; writeln(‘Tunjangan Anak : ‘,tunj:2:0); readln; end.

More Related