Advertisement
mbah_bejo

Hitung huruf vokal

Jan 24th, 2021
1,001
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 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 jmlA=0, jmlI=0,
  10.     jmlE=0, jmlU=0,
  11.     jmlO=0;
  12.     cout << "Masukkan nama :" << endl;
  13.     gets(s);
  14.     strlen(s);
  15.     while(i!=strlen(s)){
  16.         if(s[i]=='a') jmlA++;
  17.         else if(s[i]=='i') jmlI++;
  18.         else if(s[i]=='u') jmlU++;
  19.         else if(s[i]=='e') jmlE++;
  20.         else if(s[i]=='o') jmlO++;
  21.         i++;
  22.     }
  23.     cout << "Jumlah Huruf A: " << jmlA<<endl;
  24.     cout << "Jumlah Huruf I: " << jmlI<<endl;
  25.     cout << "Jumlah Huruf E: " << jmlE<<endl;
  26.     cout << "Jumlah Huruf U: " << jmlU<<endl;
  27.     cout << "Jumlah Huruf O: " << jmlO<<endl;
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement