#include using namespace std; // Count letters and vowels, ignoring spaces, until we see a digit. // Example input: // This iS an iNpuT samPLE8 // output: // There were a total of 19 letters, and 7 vowels. int main() { char ch; int num_letters = 0; int num_vowels = 0; cin >> ch; // Keep going so long as it is not a digit while ( ! ( (ch >= '0') && (ch <= '9') ) ){ // Made it in loop, so must be a letter // NOTE -- assumed here only letters and numbers entered num_letters++; // Convert to lowercase to making counting vowels easier // OR could have just checked for 'A' and 'a', etc. below char lower = ch; if ( (ch >= 'A') && (ch <= 'Z') ) { lower = ch - 'A' + 'a'; } // Count if it's a vowel if ( (lower == 'a') || (lower == 'e') || (lower == 'i') || (lower == 'o') || (lower == 'u') ) { num_vowels++; } // Get next letter. At end of loop b/c only count if not a digit cin >> ch; } cout << "There were a total of " << num_letters << " letters, "; cout << "and " << num_vowels << " vowels." << endl; return 0; }