Challenge: Vowel Counter

Lab C Beginner 10 points

Read one line of text and print how many vowels (a e i o u, small or capital) it contains.

Input

One line of text (up to 200 characters).

Output

The number of vowels.

Example

Input

Hello World

Output

3
Sample input available Sample output available
Editor
C

Hints

Read the line with fgets.

Use tolower so you only have to check small vowels.

Solution explanation

Turning each character to lower case first means we only need to compare against five letters.

Show solution
#include <stdio.h>
#include <ctype.h>

int main() {
    char line[201];
    fgets(line, 201, stdin);
    int count = 0;
    for (int i = 0; line[i] != '\0'; i++) {
        char c = tolower(line[i]);
        if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}
Output
Answer
HOME LABS COMMUNITY DASHBOARD