-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest3.c
50 lines (41 loc) · 941 Bytes
/
test3.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
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <ctype.h>
#define fo(i, a, b) for (int i = a; i <= b; i++)
#define fod(i, a, b) for (int i = b; i >= a; i--)
int main()
{
char ch;
int nVowels = 0;
int nConsonants = 0;
int nOthers = 0;
printf("Enter a string of characters: ");
ch = getchar();
while (ch != '\n')
{
ch = toupper(ch);
if (ch >= 'A' && ch <= 'Z')
{
switch (ch)
{
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
nVowels++;
break;
default:
nConsonants++;
}
}
else
{
nOthers++;
}
ch = getchar();
}
printf("Number of vowels: %d\n", nVowels);
printf("Number of consonants: %d\n", nConsonants);
printf("Number of other characters: %d\n", nOthers);
return 0;
}