Skip to content

Commit 4b7276f

Browse files
author
Christian Bender
authored
Merge pull request #368 from Ultra980/patch-1
Create vowel_counter.cpp
2 parents 7aacfc7 + e5c1ce9 commit 4b7276f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

algorithms/strings/vowel_counter.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
string s;
6+
int cnt;
7+
cout << "Enter the string: ";
8+
cin >> s;
9+
10+
cnt = 0;
11+
for ( char ch : s ) {
12+
switch ( ch ) {
13+
case 'a':
14+
case 'e':
15+
case 'i':
16+
case 'o':
17+
case 'u':
18+
cnt++;
19+
break;
20+
default:
21+
break;
22+
}
23+
}
24+
25+
cout << "The string has " << cnt << " vowels.\n";
26+
27+
return 0;
28+
}

0 commit comments

Comments
 (0)