• C

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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

amitagarwal102999Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KangaRooCommented:
Why using a switch???
   bin[number/10]++
0
amitagarwal102999Commented:
yeah I do agree It will be more efficient
Thanx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.