Wednesday, 6 September 2017

C-Program to count vowels in sentence



#include<stdio.h>
#include<string.h>

int main()
{
    int i,vowelcount=0;
    char str[100];
    printf("Enter a string\n");
    gets(str);
    for(i=0;i<strlen(str);i++)
    {
        if(str[i]=='A'||str[i]=='a'||str[i]=='e'||str[i]=='E'||str[i]=='I'
        ||str[i]=='i'||str[i]=='O'||str[i]=='o'||str[i]=='U'||str[i]=='u')
        {
            vowelcount++;
        }
    }
    printf("%d\n",vowelcount);
    return 0;
}

No comments:

Post a Comment