I have a file which contain lots of numbers. I want to find the frequancy of each range.Can somebody help me with the strategy to write this program.
-the file contain numbers say 1-1000 so the min and max are known in advance
-the user input the width eg. 10 so there should be 1000/10 =100 number of classes (width=user input variable)
the program should search and find the frequency between numbers b/w 0-199, 200-299, 300-399 until 1000. So the result should be
class Lower limit upper limit frequency Prop
0 0.000 199.000 120 0.0987
thanks alot for you help
Once you have the number of classes allocate an array of that length using malloc or calloc:
int *class;
class=calloc(classnum,size
Then read through the file and increment the appropriate class for each number:
/* num is number from file */
++class[num/classnum];
When you have processed all the number the frequency will be contained in each array element and each class can be conceptually printed as:
/* i is the class number */
class i:
Lower limit i*width
Upper limit (i+1)*width-1
frequency class[i]
I'm not sure what the Prop represents.