-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcounting no of vowels.cpp
More file actions
42 lines (37 loc) · 894 Bytes
/
counting no of vowels.cpp
File metadata and controls
42 lines (37 loc) · 894 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
41
42
// Program to find out the total vowels in a string
#include<iostream>
using namespace std;
int main()
{
char str[100];
int counter = 0;
cout << "Enter any string:- " << endl;
cin.get(str,100);
for(int i=0; str[i]!='\0'; i++)
{
switch (str[i])
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
counter++;
}
}
cout << "The total number of vowels present are:- " << counter << endl;
}
/* Algorithm used:-
1) Ask the user to enter a string.
2) Read and store the string in a variable.
3) Iterate through the characters of the string one by one.
4) Initialize one variable as 0 to store the total count of vowels.
5) For each character of the string, check if it vowel or not.
6) If it is a vowel, increment the count variable by 1.
7) Finally, print out the count variable to the user.
*/