forked from CodeToExpress/dailycodebase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumVowelsPartA.cpp
More file actions
40 lines (36 loc) · 935 Bytes
/
NumVowelsPartA.cpp
File metadata and controls
40 lines (36 loc) · 935 Bytes
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
/**
* @author: Rajdeep Roy Chowdhury<rrajdeeproychowdhury@gmail.com>
* @github: https://github.com/razdeep
* @date: 25/12/2018
**/
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
// set count = 0
int count = 0;
string str;
cout << "/* ===== Number of Vowels ===== */" << endl;
cout << "\nEnter the string: ";
cin >> str;
// Convert input string to lower case
// using transform() function and ::tolower in STL
transform(str.begin(), str.end(), str.begin(), ::tolower);
// Run a loop from 0 to string length
for (int i = 0; i < str.length(); i++)
{
if (
str[i] == 'a' ||
str[i] == 'e' ||
str[i] == 'i' ||
str[i] == 'o' ||
str[i] == 'u')
{
count++;
}
}
// Print the result
cout<<"Number of vowels in \""<<str<<"\" = "<<count<<endl;
return 0;
}