Added exmaple cbd_pennies_adv. Now calculates final value in dollars.
[C-Programming-Examples.git] / digit_count.c
blob813f7fa47dbef9b21bdbda267955b224e86df43d
1 #include <stdio.h>
3 main()
5 int c, i, nwhite, nother;
6 int ndigit[10];
8 nwhite = nother = 0;
9 for(i = 0; i < 10; i++)
10 ndigit[i] = 0;
12 while ((c = getchar()) != EOF)
13 if(c >= '0' && c <= '9')
14 ++ndigit[c-'0'];
15 else if (c == ' ' || c == '\n' || c == '\t')
16 ++nwhite;
17 else
18 ++nother;
20 printf("digits =");
21 for(i = 0; i < 10; ++i)
22 printf(" %d", ndigit[i]);
23 printf(", whitespace = %d, other = %d\n", nwhite, nother);