-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path9b.c
50 lines (50 loc) · 1.05 KB
/
9b.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<stdlib.h>
int v,c,i,va,ve,vi,vo,vu; //I'm bored of initialising each and every variable to 0! Hence I declared it globally!
// All global declarations have the default value 0 in each variable!
void main()
{
char str[20]; // should be the easiest code in your lab!
printf("Enter a sentence!\n");
scanf("%s",str);
while(str[i]!='\0')
{
if(str[i]=='a')
{
va++;
v++;
}
else if(str[i]=='e')
{
ve++;
v++;
}
else if(str[i]=='i')
{
vi++;
v++;
}
else if(str[i]=='o') // remember! while comparing a character always encose the character within 'single quotes' and NOT "double quotes"!
{
vo++;
v++;
}
else if(str[i]=='u')
{
vu++;
v++;
}
else
{
c++;
}
i++;
}
printf("The string contains %d vowels and %d consonants\n",v,c);
printf("A repeats %d times\n",va);
printf("E repeats %d times\n",ve);
printf("I repeats %d times\n",vi);
printf("O repeats %d times\n",vo);
printf("U repeats %d times\n",vu);
}
// mail mail mail! Aren't you bored of it? Sorry! :P [email protected]!