#include<stdio.h>
#include<string.h>
main()
{
char str[50];
int i,n,words=0,vowels=0,spaces=0,digits=0;
clrscr();
printf("\nEnter a string:\n ");
gets(str);
strlwr(str);
n=strlen(str);
for(i=0;i<n;i++)
{
if(str[i]==' ')
{
spaces++;
words++;
}
if(str[i]>='0'&&str[i]<='9')
digits++;
if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u')
vowels++;
}
printf("\nNumber of words= %d ",words);
printf("\nNumber of digits= %d",digits);
printf("\nNumber of Vowels= %d",vowels);
printf("\nNumber of Spaces= %d",spaces);
getch();
}
Comments
Post a Comment