oke_google

Modul 3.4

Nov 29th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char input[100];
  9.     int vokal=0, konsonan=0, kounter;
  10.     cout<<"Masukan Kalimat = ";
  11.     cin.getline(input, 100);
  12.     for(kounter=0; kounter<strlen(input); kounter++){
  13.         if(input[kounter]==' '){
  14.             cout<<"0"<<" ";
  15.         }
  16.         else{
  17.         cout<<int(input[kounter])-96<<" ";
  18.         }
  19.     }
  20.     cout<<"\nKalimat setelah dibalik = "<<strrev(input)<<endl;
  21.     for(int kounter=0; kounter<strlen(input); kounter++){
  22.         if(input[kounter]=='a' || input[kounter]=='i' || input[kounter]=='u' ||
  23.             input[kounter]=='e' || input[kounter]=='o'){
  24.             vokal++;
  25.             }
  26.         else{
  27.             konsonan++;
  28.         }
  29.     }
  30.     cout<<"Jumlah huruf vokal = "<<vokal<<endl;
  31.     cout<<"Jumlah huruf konsonan = "<<konsonan<<endl;
  32. }
Add Comment
Please, Sign In to add comment