-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvowelsConsonants.cpp
More file actions
46 lines (34 loc) · 919 Bytes
/
Copy pathvowelsConsonants.cpp
File metadata and controls
46 lines (34 loc) · 919 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
43
44
45
46
#include<iostream>
#include<cctype>
using namespace std;
void countVowelsConsonants(char myString[],int &vowels, int & consonants)
{
for(int i=0;myString[i]!='\0';i++)
{
switch(tolower(myString[i]))
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
vowels = vowels + 1;
break;
case ' ':
break;
default:
consonants = consonants + 1;
}
}
}
int main()
{
char myString[] = "hello to the world of c Hope YOU ARE DOING WELL";
int vowels, consonants;
vowels = consonants = 0;
countVowelsConsonants(myString,vowels,consonants);
cout<<myString<<endl;
cout<<"the number of vowels is "<<vowels<<
" \n and the number of consonants is "<<consonants<<endl;
return 0;
}