Program to count the number of words, characters, alphabets, vowels, consonants and digit in a line of text - 100 Most Important C# Programs

100 Most Important C# Programs

46. Program to count the number of words, characters, alphabets, vowels, consonants and digit in a line of text.

Code:

#include<stdio.h>

#include<conio.h>

main( )

{

int noa=0,nob=0,noc=0,nov=0,now=0,noch=0,l,I;

char ch,s[100];

clrscr( );

printf(“enter 2 lines of text”);

gets(s);

l=strlen(s);

for(i=0;i<1;i++)

{

switch(s[i])

{c

ase ‘a’:

case ‘e’:

case ‘i’:

case ‘o’:

case ‘u’:

case ‘A’:

case ‘E’:

case ‘I’:

case ‘O’:

case ‘U’:

nov++;

break;

}

if(isalpha(s[i]))

noa++;

if(isdigit(s[i]))

nod++;

if(noa[i]==’ ‘) && (noa[i+1]!=’ ‘)

now++;

}

noch=l-nob;

noc=noa-nov;

printf(total no of words %d”,now);

printf(total no of characters(without

blanks)%d”,noch);

printf(total no of characters(including

blanks)%d”,l);

printf(total no of alphabets

%d”,noa);

printf(total no of vowels

%d”,nov);

printf(total no of characters %d”,noc);

printf(total no of digits %d”,nod);

getch( );

}