#include <stdio.h>
int is_vowel(char c){
return c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y';
}
int main() {
char s[201];
scanf("%s", s);
int count=0;
for (int i = 0;s[i]!='\0'; i++) {
if (is_vowel(s[i])){
count++;
}
}
printf("%d\n", count);
return 0;
}
This program reads a single word from input, counts how many vowels (a, e, i, o, u, y) it contains, and prints the count. The `is_vowel` function checks if a character is one of those lowercase vowels.
- The `is_vowel` function only checks lowercase letters. If the input contains uppercase vowels like 'A' or 'E', they will not be counted. Consider how to handle both cases.
- The program uses `scanf("%s", s)` which stops reading at the first whitespace. If the input contains spaces or multiple words, only the first word is processed. Think about whether this matches the intended behavior.