Advertisement
Guest User

Vowel Counter

a guest
Jun 27th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4. void vowelCount(string wordInput, int& aCount, int& eCount, int& iCount, int& oCount, int& uCount);
  5. int main()
  6. {
  7.     cout << "Enter a string for vowel analyzing : ";
  8.     int aCount, eCount, iCount, oCount, uCount;
  9.     string wordInput;
  10.     cin >> wordInput;
  11.     vowelCount(wordInput, aCount, eCount, iCount, oCount, uCount); 
  12.     cout << "Number of a's : " << aCount << endl;
  13.     cout << "Number of e's : " << eCount << endl;
  14.     cout << "Number of i's : " << iCount << endl;
  15.     cout << "Number of o's : " << oCount << endl;
  16.     cout << "Number of u's : " << uCount << endl;  
  17.  
  18.     system("read");    
  19.     return 0;
  20. }
  21. void vowelCount(string wordInput, int& aCount, int& eCount, int& iCount, int& oCount, int& uCount){
  22.     for(int i = 0; i <= wordInput.length(); i++){
  23.         char temp = wordInput[i];
  24.         switch (temp){
  25.             case 'a':
  26.             case 'A':
  27.                 aCount++;
  28.                 break;
  29.             case 'e':
  30.             case 'E':
  31.                 eCount++;
  32.                 break;
  33.             case 'i':
  34.             case 'I':
  35.                 iCount++;
  36.                 break;
  37.             case 'o':
  38.             case 'O':
  39.                 oCount++;
  40.                 break;
  41.             case 'u':
  42.             case 'U':
  43.                 uCount++;
  44.                 break;
  45.         }  
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement