Challenge: Count the Vowels

Lab C++ Beginner 10 points

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

Input

One line of text (it may contain spaces).

Output

One integer.

Example

Input

Hello World

Output

3
Sample input available Sample output available
Editor
C++

Hints

Use getline(cin, line) because the text has spaces.

Turn each char into lower case with tolower before comparing.

Solution explanation

Lower-casing each letter first means you only have to check five letters instead of ten.

Show solution
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main() {
    string line;
    getline(cin, line);
    int count = 0;
    for (char c : line) {
        char lower = tolower(c);
        if (lower == 'a' || lower == 'e' || lower == 'i' || lower == 'o' || lower == 'u') {
            count++;
        }
    }
    cout << count << "\n";
    return 0;
}
Output
Answer
HOME LABS COMMUNITY DASHBOARD