C program to find number of Occurrences of Vowels, Consonants, Words, Spaces and Special Characters in the Given Statement.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
void main()
{
char s[100];
int vow=0,cons=0,spc=0,punc=0,l,i;
clrscr();
printf(“enter the statement\n”);
gets(s);
l=strlen(s);
for(i=0;i<l;i++)
{
if(isalpha(s[i]))
{
if(s[i]==’a’||s[i]==’e’||s[i]==’i’||s[i]==’o’||s[i]==’u’)
{
vow++;
}
else
{
cons++;
}
}
if(isspace(s[i])
{
spc++;
}
if(ispunct(s[i]))
{
punc++;
}
}
printf(“\nno.of words=%d”,spc+1);
printf(“\nno.of vowels=%d”,vow);
printf(“\nno.of consonants=%d”,cons);
printf(“\nno.of space=%d”,spc);
printf(“\nno.on special characters=%d”,punc);
getch();
}
Comments
Post a Comment