C program to print vowels in a string - C Program to calculate frequency of vowels in a String




 C Program to calculate frequency of vowels in a string

Learn C - C tutorial - C Program to calculate frequency of vowels in a string - C examples - C programs

C program to print vowels in a string

  • C program to count number of vowels in a string For example, In the string "C programming" there are three vowels 'o', 'a' and 'i'.
  • In the program both lower and upper case are considered i.e 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O' and 'U'.
  • We undergoes checking every character in the input string, if it's a vowel then counter is incremented by one, consonants and others characters are ignored.
#include <stdio.h>
void main()
{
    int a=1,e=1,i=1,o=1,u=1,sum=0;
    char c;
    while ((c=getchar())!=EOF)
    {
        if (c=='a'||c=='A')
            a=a+1;
        if (c=='e'||c=='E')
            e=e+1;
        if (c=='i'||c=='I')
            i=i+1;
        if (c=='o'||c=='O')
            o=o+1;
        if (c=='u'||c=='U')
            u=u+1;
    }
    sum=a+e+i+o+u;
    printf("\nFrequency of vowel 'a' is %d.",a);
    printf("\nFrequency of vowel 'e' is %d.",e);
    printf("\nFrequency of vowel 'i' is %d.",i);
    printf("\nFrequency of vowel 'o' is %d.",o);
    printf("\nFrequency of vowel 'u' is %d.",u);
    printf("\nsum of vowel frequeny %d.",sum);
}
Frequency of vowel 'a' is 1.
Frequency of vowel 'e' is 1.
Frequency of vowel 'i' is 1.
Frequency of vowel 'o' is 1.
Frequency of vowel 'u' is 1.
sum of vowel frequeny 5.


View More Quick Examples


Related Searches to C program to print vowels in a string - C Program to calculate frequency of vowels in a String

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×