Upcoming SlideShare
×

# 5. struktur kontrol if, select case

2,645

Published on

programmer

1 Comment
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• thats right

Are you sure you want to  Yes  No
• Be the first to like this

Views
Total Views
2,645
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
27
1
Likes
0
Embeds 0
No embeds

No notes for slide

### 5. struktur kontrol if, select case

1. 1. STRUKTUR KONTROL IF, SELECT CASE DAN STATEMENT GOTOa. Struktur IF Bentuk Umum : 1. IF kondisi THEN statement 2. IF kondisi THEN statement_1 ELSE statement_2 3. IF kondisi_1 THEN IF kondisi_2 THEN statement_1 ELSE statement_2 4. IF kondisi_1 THEN BEGIN IF kondisi_2 THEN statement_1 ELSE statement_2 END 1
2. 2. Contoh : If - ThenVar NilaiUjian : real; Ket : string[11];Begin Ket := ‘Tidak Lulus’; Write(‘Nilai yang didapat ? ‘); Readln(NilaiUjian); If NilaiUjian > 60 Then Ket :=’Lulus’; Writeln(Ket);End. 2
3. 3. Hasilnya : Nilai yang didapat ? 70Lulus 3
4. 4. Contoh : If - Then - elseVar NilaiUjian : real; Ket : string[11];Begin Write(‘Nilai yang didapat ? ‘); Readln(NilaiUjian); If NilaiUjian > 60 Then Writeln(‘Lulus’); Else Writeln(‘Tidak Lulus’);End. 4
5. 5. Hasilnya : Nilai yang didapat ? 70 Lulus 5
6. 6. Struktur CASEBentuk Umum : Case – Of CASE ekspresi OF Case label list 1 : statement_1; Case label list 2 : statement_2; Case label list n : statement_n; END; 6
7. 7. Bentuk Umum : Case - Of…ElseCASE ekspresi OF Case label list 1 : statement_1; Case label list 2 : statement_2; Case label list n : statement_n; ELSE statement;END; 7
8. 8. PROGRAM nilai; VAR nil : CHAR; BEGIN WRITE(Nilai Numerik yang didapat :); READLN(nil); CASE nil OF A: WRITELN(SANGAT BAIK); B: WRITELN(BAIK); C: WRITELN(CUKUP); D: WRITELN(KURANG); E: WRITELN(SANGAT KURANG ); END; END. 8
9. 9. hasil : Nilai Numerik yang didapat : B BAIK 9
10. 10. Contoh :Var Nilai :char;Begin Write(‘Nilai huruf yang didapat’);readln(Nilai); CASE Nilai OF ‘A’ : writeln (‘T-shirt’); ‘B’ : writeln (‘Sepatu’); ‘C’: writeln (‘Topi’); Else Writeln(‘Pilihan hanya A,B,C’);End. 10
11. 11. Struktur GOTO• Bentuk Umum : GOTO label statement;Contoh : Label 10,selesai; Begin Writeln(‘Bahasa’); Goto 100; Writeln(‘Basic’); 100; Writeln(‘Pascal’); Goto selesai; Writeln(‘Cobol’); Selesai; End. 11
1. #### A particular slide catching your eye?

Clipping is a handy way to collect important slides you want to go back to later.