frequency distribution

How do I get a C program to 1) input any number of one or two digit integer numbers. I.e., each numb is 0 to 99. 2) The program counts the number of these values which falls into 10 "bins" where the bins are 0-9, 10-19, 20-29, etc. ......80-89, 90-99  3)The program computes the average of allthe numbers entered.  4)The program outputs the average and frequency distribution that looks like this (for example):
0-9    x
10-19  xxx
20-29  xxxx
30-39  xxxxxx
40-49  xxxxxxx
50-59  xxxxxxx
60-69  xxxxxxxxxxx
70-79  xxxxxx
80-89  xxxxxxxxx
90-99  xxx  
Please help in any way that you can.
minniemeAsked:
Who is Participating?
 
amitagarwal102999Connect With a Mentor Commented:
Here you can take an int array of 10 depends upon the number of bin. You read numbers one by one and send to a function for instance
AssignBin(int number) in which you can put switch case
for instance
switch(number)
{
case 0-9
bin[0]++;
break;
}
so whenever a new number will arrive you will increase the count of that particular bin. And then finally you can print for instance u have two frequency in first bin
printf(" 0 - 9");
for(i=0;i<2;i++)
    printf("x");
for calculating average you have to use the formuals get the sum of all the numbers and divide it by the number of the integer.
If this don't suffice please let me know your problem
amit
0
 
KangaRooCommented:
Why using a switch???
   bin[number/10]++
0
 
amitagarwal102999Commented:
yeah I do agree It will be more efficient
Thanx
0
All Courses

From novice to tech pro — start learning today.