1 / 5

S T R I N G

S T R I N G. Dalam C++, String adalah kumpulan (array) dari karakter. Bentuk : char Nama Variabel_string[jml karakter] Contoh : char kata[20] ; Dalam C++ terdapat beberapa fungsi siap pakai yang berguna untuk memanipulasi data string.

amandla
Download Presentation

S T R I N G

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. S T R I N G

  2. Dalam C++, String adalah kumpulan (array) dari karakter. Bentuk : char Nama Variabel_string[jml karakter] Contoh : char kata[20] ; Dalam C++ terdapat beberapa fungsi siap pakai yang berguna untuk memanipulasi data string. Untuk menggunakan fungsi-fungsi tersebut kita harus menyertakan file header : string.h. didalam program

  3. DaftarFungsiuntuk string

  4. #include<iostream.h> #include<conio.h> #include<string.h> main() { char kata[100],i,b[]="_________________________________________"; gotoxy(15,6);cout << "PROGRAM UNTUK MEMBALIK URUTAN KARAKTER" << endl; gotoxy(22,7);cout << "DALAM SUATU KALIMAT" << endl; gotoxy(15,8);cout << b << endl; gotoxy(20,10);cout << "Masukan sebuah kalimat : "<< endl; gotoxy(20,12);cin.get(kata,100); clrscr(); gotoxy(20,9);cout << b << endl; gotoxy(20,11);cout << "kalimat Sebelum dibalik " << endl; gotoxy(25,13);cout <<'"' << (kata) << '"' << endl; gotoxy(20,15);cout << "Kalimat setelah dibalik "; gotoxy(25,17);cout << '"' << strrev(kata) << '"'<<endl; gotoxy(20,19);cout << b << endl; return 0 ; }

  5. #include<iostream.h> #include<conio.h> #include<string.h> main() { static char huruf[10] = {'A','I','U','E','O','a','i','u','e','o'} ; char *ptrkar ; char kar,nama[20]; char grs[]=“ ______________________"; int i,pjg,vokal,konsonan; gotoxy(15,3);cout << "PROGRAM UNTUK MENGHITUNG HURUF VOKAL & KONSONAN"; gotoxy(10,4);cout <<grs ; gotoxy(10,8);cout <<grs ; gotoxy(20,6);cout << "MASUKKAN SEBUAH KATA : "; cin >> nama; clrscr(); pjg = strlen(nama); vokal = 0,konsonan = 0 ; for (i=0 ; i<pjg;i++) { kar = nama[i]; ptrkar = strchr(huruf,kar); if (ptrkar !=0) { vokal = vokal + 1; } else { konsonan = konsonan +1 ; } } gotoxy(10,5);cout<< grs ; gotoxy(15,7);cout<< "KATA " <<"' "<< strupr(nama)<<" '" << " Terdiri dari :"; gotoxy(20,9);cout<< vokal << " Huruf Vokal " ; gotoxy(20,10);cout<< konsonan << " Huruf Konsonan" ; gotoxy(10,12);cout<< grs ; return 0 ; }

More Related