count number of vowels in a string in c

Solutions on MaxInterview for count number of vowels in a string in c by the best coders in the world

showing results for - "count number of vowels in a string in c"
Rania
27 Aug 2020
1 #include<stdio.h>
2  2 int num_vowels(char*);
3  3 void main()
4  4 {
5  5 char s[10];
6  6 int c;
7  7 printf("Enter the string...\n");
8  8 scanf("%s",s);
9  9 c=num_vowels(s);
10 10 printf("%d",c);
11 11 printf("\n");
12 12 }
13 13 int num_vowels(char*s)
14 14 {
15 15 int c=0;
16 16 int i;
17 17
18 18 for(i=0;s[i]!='\0';i++)
19 19 if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u'||s[i]=='A'||s[i]=='E'||s[i]=='I'||s[i]=='O'||s[i]=='U')
20 20 c++;
21 21 return c;
22 22 }
23 23
24 24
25 25
26 26
27 27
28 28
29~