Advertisement
mbah_bejo

Hitung karakter

Jan 24th, 2021
952
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <string.h>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.     char s[256];
  8.     int i=0;
  9.     int jmlvokal=0, jmlnonvokal=0;
  10.     cout << "Masukkan nama :" << endl;
  11.     gets(s);
  12.     cout << "Panjang Kalimat: " << strlen(s)<<endl;
  13.     while(i!=strlen(s)){
  14.         //hitung huruf vokal
  15.         if(s[i]=='a'||s[i]=='i'||s[i]=='u'||s[i]=='e'||s[i]=='o') jmlvokal++;
  16.         //hitung huruf nonvokal
  17.         else jmlnonvokal++;
  18.         i++;
  19.     }
  20.     cout << "Jumlah Huruf Vokal: " << jmlvokal<<endl;
  21.     cout << "Jumlah Huruf Nonvokal: " << jmlnonvokal;
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement