This program is to count the number of words,vowels and consonants of a string.Here is my code.Please post your comment.I do not know whether I need to change anything.
#include <stdio.h>
int main()
{
char a,b =' ';
int vowel=0,c=0,count=0;
printf("Please press '*' to terminate.\n\n");
while(scanf("%c",&a)==1)
{
if(a=='*') break;
else if((a>='a' && a<='z') || (a>='A' && a<='Z')){
if(!((b>='a' && b<='z')||(b>='A' && b<='Z'))) {
count++;
}
if(a=='a' || a=='e' || a=='i' || a=='o' || a=='u' || a=='A' || a=='E' || a=='I' || a=='O' || a=='U') vowel++;
if(!(a=='a' || a=='e' || a=='i' || a=='o' || a=='u' || a=='A' || a=='E' || a=='I' || a=='O' || a=='U')) c++;
}
else if(a=='\n'){
printf("The string consists of :\n\t%d word(s).\n\t%d vowel(s).\n\t%dconsonant(s).\n\n",count,vowel,c);
vowel=0;
c=0;
count=0;
}
b=a;
}
return 0;
}