#include /* count digits, white space, and others */ int main() { int c, i, nwhite, nother; int ndigit[10]; int nchar[26]; nwhite = nother = 0; for (i = 0; i < 26; ++i) { if (i < 10) { ndigit[i] = 0; } nchar[i] = 0; } while ((c = getchar()) != EOF) { if (c >= '0' && c <= '9') { ++ndigit[c - '0']; } else if (c == ' ' || c == '\t' || c == '\n') { ++nwhite; } else if (c >= 'a' && c <= 'z') { ++nchar[c - 'a']; } else { ++nother; } } printf("digits ="); for (i = 0; i < 10; ++i) { printf(" %d", ndigit[i]); } printf("\nchars ="); for (i = 0; i < 26; ++i) { printf(" %d", nchar[i]); } printf("\nwhite space = %d\nother = %d\n", nwhite, nother); return 0; }