-
Notifications
You must be signed in to change notification settings - Fork 1
/
ex07.cpp
40 lines (35 loc) · 915 Bytes
/
ex07.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <string>
#include <cctype>
int main()
{
std::string word = "";
int vowels = 0, consonants = 0, others = 0;
std::cout << "Enter words (q to quit):" << std::endl;
while (std::cin >> word && word != "q")
{
if (isalpha(word[0]))
{
switch (word[0])
{
case 'A': case 'a':
case 'E': case 'e':
case 'I': case 'i':
case 'O': case 'o':
case 'U': case 'u':
case 'Y': case 'y':
vowels++; break;
default:
consonants++;
}
}
else
{
others++;
}
}
std::cout << vowels << " words beginning with vowels.\n"
<< consonants << " words beginning with consonants.\n"
<< others << " others.\n";
return 0;
}