Wednesday, 10 July 2019

write a programe to find the number of vowels and consonants in a text string

#include<stdio.h>
#include<string.h>
int main()
{
    char str[30];
    int vowl=0,cons=0,i=0;
    clrscr();
    printf("Enter a string: ");
    gets(str);
    while(str[i]!='\0')
    {
        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')
            vowl++;
        else
            cons++;
        i++;
    }
    printf("\nNumber of Vowels=%d",vowl);
    printf("\nNumber of Consonants=%d",cons);
}

No comments:

Post a Comment