SlideShare a Scribd company logo
1 of 11
Download to read offline
STRUKTUR KONTROL IF, SELECT CASE
              DAN STATEMENT GOTO
a. 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
Contoh : If - Then
Var
     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
Hasilnya :
  Nilai yang didapat ? 70
Lulus




                            3
Contoh : If - Then - else

Var
        NilaiUjian    : real;
        Ket           : string[11];
Begin
        Write(‘Nilai yang didapat ? ‘);
        Readln(NilaiUjian);
        If NilaiUjian > 60 Then
                Writeln(‘Lulus’);
        Else
                Writeln(‘Tidak Lulus’);
End.
                                          4
Hasilnya :
 Nilai yang didapat ? 70
 Lulus




                           5
Struktur CASE

Bentuk 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
Bentuk Umum :       Case - Of…Else

CASE ekspresi OF
               Case label list 1 : statement_1;
               Case label list 2 : statement_2;


               Case label list n : statement_n;
           ELSE                      statement;

END;

                                                  7
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
hasil :
          Nilai Numerik yang didapat : B
          BAIK




                                           9
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
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

More Related Content

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

5. struktur kontrol if, select case

  • 1. STRUKTUR KONTROL IF, SELECT CASE DAN STATEMENT GOTO a. 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. Contoh : If - Then Var 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. Hasilnya : Nilai yang didapat ? 70 Lulus 3
  • 4. Contoh : If - Then - else Var 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. Hasilnya : Nilai yang didapat ? 70 Lulus 5
  • 6. Struktur CASE Bentuk 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. Bentuk Umum : Case - Of…Else CASE 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. 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. hasil : Nilai Numerik yang didapat : B BAIK 9
  • 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. 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