When user input number from 1 - 26 (which mean a
to z
), how to show the the letter and count how many vowel and consonant inside it.
Example: U
To show the letters, you can use a for loop, using a char as index.
int n = 13;
unsigned int vowel = 0;
unsigned int consonant = 0;
int a = (int)'a';
for (char letter = 'a'; (int)letter < a + n; letter++) {
cout << letter << " ";
if (is_vowel(letter)) vowel++;
else consonant++;
}
cout << std::endl << "vowels: "<< vowel << " consonants: " << consonant << std::endl;
So, you must implement the is_vowel method.