1 / 11

IF statement

IF statement. Achmad Yasid , S. Kom .,M. Kom .,MBA D3 Manajemen Informatika 2013. If statement. M erupakan operator percabangan yang digunakan untuk menentukan pilihan atas beberapa kondisi yang merupakan syarat terhadap pilihan yang sudah ditentukan . . Simple If statement.

dillon
Download Presentation

IF statement

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. IF statement AchmadYasid, S.Kom.,M.Kom.,MBA D3 ManajemenInformatika 2013

  2. If statement • Merupakanoperator percabangan yang digunakanuntukmenentukanpilihanatasbeberapakondisi yang merupakansyaratterhadappilihan yang sudahditentukan.

  3. Simple If statement BentukUmum = If kondisithen statemen; Contoh • If Nilai > 85 then keterangan:= ‘A’;

  4. Compound if conditions, danmultiple statements Kita dapatmempunyailebihdarisatukondisidanlebihdarisatu statement Contoh : if (condition1) And (condition2)   // Both conditions must be satisfiedthenbegin       statement1;       statement2;       ...     end              // Notice no terminating ';' - still part of 'if'elsebegin       statement3;       statement4;       ...end;

  5. Nested If statements BentukUmum If kondisithen statement1 Else If kondisithen statement2 Else ……………. statement3 ;

  6. If untukkondisiMajemuk • Contoh If nilai>= 80 then Grade = ‘A’ Else if nilai>= 70 then Grade= ‘B’ else if nilai>= 60 then Grade= ‘C’ else grade = ‘E’;

  7. Case Statements • Statemen If digunakanpadasaatkitamemilikiduabuahkemungkinan, sedangkanapabilalebihdariduakemungkinanataualternatif, kitadapatmenggunakan Case

  8. Simple numerical case statemen

  9. Using the otherwise clause

  10. Using enumeration case values

  11. Latihan • Buat program untukmenentukannilaikelulusan. Jikanilai >= 70 tampilkan ‘Lulus’, jikakurangdari 70 makatampilkan ‘Tidak lulus’

More Related