COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
vowel.cpp
Go to the documentation of this file.
1
/*
2
This program prompts the user to input a sequence of characters and outputs the number of vowels
3
*/
4
5
#include <iostream>
6
#include <string>
7
using namespace
std;
8
9
bool
isVowel
(
char
a){
10
string
vowels =
"A E I O U a e i o u"
;
11
// string.find(char) will return string::npos if not found
12
// first character is index 0
13
return
vowels.find(a) != string::npos;
14
}
15
16
17
int
main
()
18
{
19
int
n;
20
int
numVowel = 0;
21
char
c;
22
cin >> n;
23
24
for
(
int
i = 0; i < n; ++i)
25
{
26
cin >> c;
27
if
(
isVowel
(c))
28
numVowel++;
29
}
30
31
cout <<
"Number of vowels = "
<< numVowel << endl;
32
33
return
0;
34
}
main
int main()
Definition
vowel.cpp:17
isVowel
bool isVowel(char a)
Definition
vowel.cpp:9
Module5
vowel.cpp
Generated on Sun Sep 29 2024 16:39:53 for COMP2113 by
1.12.0