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>
7using namespace std;
8
9bool 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
17int 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}
int main()
Definition vowel.cpp:17
bool isVowel(char a)
Definition vowel.cpp:9