Read the question, write C on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read one word and print how many vowels (a, e, i, o, u) it contains.
Count both cases — lowercase each character before testing.
Input. One line: a word.
Output. One integer: the vowel count.
Examples
Input
Programming
Output
3
Input
sky
Output
0
Hint
- Read a word with scanf("%1023s", word).
- #include <ctype.h>, then tolower each character before comparing.
Show correct code
Peek only after you have tried. You can still Check your own version.
#include <stdio.h>
#include <ctype.h>
int main(void) {
char word[1024];
if (scanf("%1023s", word) != 1) { printf("0\n"); return 0; }
int count = 0;
for (int i = 0; word[i]; i++) {
char l = tolower((unsigned char)word[i]);
if (l == 'a' || l == 'e' || l == 'i' || l == 'o' || l == 'u') count++;
}
printf("%d\n", count);
return 0;
}
main.cC17 · gcc · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.