Write a function which accepts a string as a parameter and returns the number of vowels in the string.
int getVowles(char *str) { int j=0,i=0; for(i=0;str!='\0\;i++) { switch(str) { case 'a': case 'A': case 'e': case 'E': case 'I': case 'i': case 'o': case 'O': case 'u': case 'u':j++; break; } } return j; }
Try this: int count_vowel(char str[]) { char str1[20]; int i,flag=0; strcpy(str1,str); for(i=0;str1;i++) { if((str1=='a')||(str1=='e')||(str1=='o')||(str1=='u')) flag++ } return flag; }
This will run : count_vowel(word) char word[50] { char ch; int v=0,i=0; while ((ch=word)!='\0') { switch(ch) { case 'a': case 'e': case 'i': case 'o': case 'u': v++; } i++; } return(v); }