Completely Solved C, C++ Programs Assignment.




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

Filed Under:

Problem 46. C Program to count the number of words, characters, alphabets, vowels, consonants and digit in a line of text.
#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])
{
case ‘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( );
}
C compiler: gcc 4.1.2

 Back to main directory: Sample C Program | Software Practical | Solved C Assignment


Get Free Programming Tutorials and Solved assignments