1 / 11

PENGENALAN STRCMP

PENGENALAN STRCMP. STRCMP: Digunakan untuk membandingkan string pertama dengan string kedua File header yang disertakan adalah: string.h. Contoh penggunaan strcmp. Tampilan input:. #include <string.h> #include <iostream.h> #include <conio.h> main() { int a,b;

elewa
Download Presentation

PENGENALAN STRCMP

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. PENGENALAN STRCMP

  2. STRCMP: Digunakan untuk membandingkan string pertama dengan string kedua File header yang disertakan adalah: string.h

  3. Contoh penggunaan strcmp Tampilan input: #include <string.h> #include <iostream.h> #include <conio.h> main() { int a,b; char kode[3],jurusan[30]; clrscr(); cout<<"masukkan kode kelas[TK/MI]:";cin>>kode; a=strcmp(kode,"TK"); b=strcmp(kode,"MI"); if(a==0) strcpy(jurusan,"teknik komputer"); else if(b==0) strcpy(jurusan,"manajemen komputer"); else strcpy(jurusan,"tidak terdaftar"); cout<<"jurusan yang diinput adalah:"<<jurusan; getch(); } Ketentuan: Jika kelas yang dipilih: MI maka pada jurusan “Manajemen informatika” TK maka jurusan “Teknik komputer” Selain itu “tidak terdaftar”

  4. Contoh Tampilan input: Tampilanotput:

  5. if(strcmpi(kode,"EKS")==0) { strcpy(jenis,"ESKLUSIF"); harga=1000000; } else if(strcmpi(kode,"BNS")==0) { strcpy(jenis,"BISNIS"); harga=800000; } else if(strcmpi(kode,"EKN")==0) { strcpy(jenis,"EKONOMI"); harga=600000; } else { strcpy(jenis,"AndaSalahKode"); harga=0; } total=jumbel*harga; clrscr(); cout<<"==============================="<<endl; cout<<" STRUK PEMBAYARAN "<<endl; cout<<"==============================="<<endl; cout<<"NamaPenumpang : "<<nama<<endl; cout<<"JenisBis : "<<jenis<<endl; cout<<"HargaTiket : "<<harga<<endl; cout<<"jumlahBeli : "<<jumbel<<endl; cout<<"Total : "<<total; getch(); #include <stdio.h> #include <conio.h> #include <iostream.h> #include<string.h> main() { char nama[15],kode[5],jenis[15]; intharga,jumbel,total; clrscr(); puts("*******************************"); puts("=========TRAVEL JALAN SANTAI========="); puts("******************************"); puts("KODE BIS JENIS HARGA "); puts("-------------------------------------"); puts("EKS ESKLUSIF RP.1000000 "); puts("BNS BISNIS RP.800000 "); puts("EKN EKONOMI RP.600000 "); puts("-------------------------------------"); printf("input namapenumpang : ");cin>>nama; printf("input Kodebis : ");cin>>kode; cout<<"Input JumlahBeli : ";cin>>jumbel;

  6. Perulangan ( Looping )

  7. Contoh:

  8. 4.Nested for(for bersarang) Yaitusuatuperulangan for didalam for Bentukumum: for (inisialisasi ;syaratpengulangan; pengubahnilaipencacah) { for (inisialisasi ;syaratpengulangan; pengubahnilaipencacah) { Peryataan /perintah; } }

  9. Latihan – latihan:

More Related