this will count the words properly even if there are several spaces in a row... if the sentence ends in spaces, then also this will work... but if the sentence starts with spaces, it wont work... any suggestions?Code:#include <string.h> #include <ctype.h> void main() { typedef char* string; char s[100]; int i,alpha=0,space=0; printf("Enter a sentence : "); gets(s); l=strlen(s); for (i=0;i<l;i++) { if( isalpha(s[i]) ) alpha++; else if(isspace(s[i]) ) { if(s[i+1]!=' ' && i!=l-1 ) space++; } } printf("\nAlphabets = %d",alpha); printf("\nWords = %d",space+1); getch(); }