Number of Vowels in a string

Write a program to count a number of vowels in a given string.

vowels = {a,e,i,o,u}




Example

Input

abc

Output

1

Input

education

Output

5




Logic

initialize count as 0

Iterate the string using loop till null character

    compare each character with vowels {'a',' e', 'i', 'o', 'u'}

    if equal

       increment count by 1

Finally, print the count.




Program

Example

#include<stdio.h>

int main()
{
    char str[100];
    int i,count = 0;
    
    scanf("%s",str);
    
    //iterate the string
    for(i = 0; str[i] != '\0'; i++)
    {
        //check each char with any vowel. 'a','e','i','o','u'.
        if( str[i] == 'a' ||
            str[i] == 'e' ||
            str[i] == 'i' || 
            str[i] == 'o' || 
            str[i] == 'u'    )
        {
            //if equal increment the count
            count++;
        }
    }
    
    //print the result
    printf("vowel count = %d\n",count);
    
    return 0;
}


Topics You Might Like