Advertisement
adambkehl

Assignment #2 (2/2) - Page 303 #7

Feb 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6.     string words = "";
  7.     int vowels = 0, consonants = 0;
  8.     char c;
  9.     cout << "Enter words (q to quit): ";
  10.     do {
  11.         cin >> words;
  12.  
  13.         if (isalpha(c = words[0])) {
  14.             if (c == 'a' || c == 'e' || c == 'i' ||
  15.                 c == 'o' || c == 'u' || c == 'A' ||
  16.                 c == 'E' || c == 'I' || c == 'O' ||
  17.                 c == 'U')
  18.                 vowels++;
  19.             else consonants++;
  20.         }
  21.     } while (words != "q");
  22.     consonants--;
  23.  
  24.     cout << endl << "Vowels: " << vowels << endl << "Consonants: " << consonants << endl;
  25.  
  26.     cin.get(), cin.get();
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement