-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathWorkshop2-Program5.c
41 lines (38 loc) · 911 Bytes
/
Workshop2-Program5.c
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
//Program 5: Print out the number of vowels, consonants and others
#include <stdio.h>
#define ENTER 10
int main()
{
int others = 0, vowels = 0, consonants = 0;
char c;
printf("Enter a string: ");
while ( c != ENTER)
{
c = getchar();
if ((('a' <= c) && (c <= 'z')) || (('A' <= c) && (c <= 'Z')))
{
switch (c)
{
case 'a':
case 'i':
case 'u':
case 'e':
case 'o':
case 'A':
case 'I':
case 'U':
case 'E':
case 'O':
vowels = vowels + 1;
break;
default:
consonants = consonants + 1;
}
}
else others = others + 1;
}
printf("Number of vowels: %d\n", vowels);
printf("Number of consonant: %d\n", consonants);
printf("Number of others: %d\n", others-1);
return 0;
}