Bug found in Primes program.
[C-Programming-Examples.git] / cbd_rand_dist.c
blob6b395d6de528e8d2053e7dd3cdaa4033ad122993
1 /*
2 * User inputs integer number. This number represents the count of random numbers to generate.
3 * Each of these numbers is counted in an array of 10 integers.
4 * When the number generation is complete, a chart of the distribution is sent to stdout.
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
10 int main()
12 int count;
13 int tally[10] = { '0' };
15 printf("Number of Random Integers to Generate: ");
16 scanf("%d", &count);
17 while(count > 0)
19 tally[rand()%10]++;
20 --count;
23 while(count < 10)
25 printf("%d->%d\n", count, tally[count]);
26 ++count;
28 return 0;