Home » Sometech » WAP to count number of vowel, blanks and consonants in a given STRING.

WAP to count number of vowel, blanks and consonants in a given STRING.

#include <stdio.h>

#include<conio.h>

#define S 80

void main()

{

 

char string[S];

int i, vowel_count,blank_count,consonant_count;

 vowel_count=blank_count=consonant_count=0;

clrscr();

printf(“Enter the text :\n”);

gets(string);

 

i=0;

while(string[i]!=”)

{

 

 if(string[i]==’a’||string[i]==’A’||

    string[i]==’e’||string[i]==’E’||

    string[i]==’i’||string[i]==’I’||

    string[i]==’o’||string[i]==’O’||

    string[i]==’u’||string[i]==’U’)

 vowel_count++;

 

else if(string[i]==’\t’||string[i]==’ ‘)

      blank_count++;

   

 else if(string[i]>’a’&& string[i]<=’z’ ||

                 string[i]>’A’&& string[i]<=’Z’)

              consonant_count++;

 

i++;

}

 

 

 

 

 

 

printf(“\nNumber of vowels in text     : %d”,vowel_count);

printf(“\nNumber of blanks in text     : %d”,blank_count);

printf(“\nNumber of consonants in text : %d”,consonant_count);

getch();

}

 

Advertisements

SoME Tech

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

%d bloggers like this: