/* * count2.c * New functions * isspace() true if space, tab, or newline * isalpha() true if alphabetic * islower() true if lower-case * isdigit() true if 0-9 */ #include #include int main(void) { char cc; // declare char int words, lower, upper, num, other; // declare int's words = lower = upper = num = other = 0; // initialize int's while ( (cc=getchar()) != EOF ) // loop until end of file { if ( isspace(cc) ) // if value of cc is a space, do block { words=(words+1); // increment words by one } else { if( isalpha(cc) ) // if value of cc is an alpha numeric, do block { if ( islower(cc) ) // if lowercse , do loop block { lower =(lower+1); // increment lower counter } else // if not lower, do block { upper=(upper+1); // inrement upper counter } } else { if ( isdigit(cc) ) { num=(num+1); } else { other = (other+1); } } } } printf("\nThe input consisted of : \n"); printf("%d words, \n", words); printf("%d lowercase letters.\n", lower); printf("%d uppercase letters.\n", upper); printf("%d digits, and \n", num); printf("%d miscellaneous charaters.\n", other); return 0; }