Get Answers to all your Questions

header-bg qa

Write a program to count the number of vowels and consonants from a given text field?

Answers (1)

best_answer

#include <string.h>

int main()

    char s[1000];  

    int i,vowels=0,consonants=0;

    printf("Enter  the string : ");

    gets(s);

    

    for(i=0;s[i];i++)  

    

     if((s[i]>=65 && s[i]<=90)|| (s[i]>=97 && s[i]<=122))

    

            if(s[i]=='a'|| s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u'||s[i]=='A'||s[i]=='E'||s[i]=='I'||s[i]=='O' ||s[i]=='U')

      vowels++;

            else

             consonants++;

        

 

    

    printf("vowels = 0 ",vowels);

    printf("consonants = 0 ",consonants);

    

    return 0;

Posted by

Deependra Verma

View full answer