Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help: Program function!

Status
Not open for further replies.

Stjuice

Programmer
Aug 22, 2001
4
US
I'm writing a program where i have to output a sorted and unsorted list of numbers. I ran into a block when I had to output the Mean, Median, Mode, and the numbers Frequency (the amount of times it appears in the list)...
could someone help me out?
THank you
 
Well the Mean is just all then numbers added up divided by the amount of numbers. The Median is the number in the middle or the two numbers in the middle if an even amount of numbers exist and the mode is the number(s) with the highest frequency. Shouldnt be too hard once you get the sort done. Look into qsort (built in sort function) or look on the web for bubble sort. The easiest sort, but its time grows too fast when given a large amount to sort. I would think that because this sounds like a school project, you wouldnt have a very large amount of numbers and bubble sort would work fine.


Matt
 
A little more detail regarding the median.

The median in the case of an even number of samples is the mean of the two middle samples. For example:

The sample set: {1 ,4, 5, 6, 9, 21} has a median equal to: 5 + 6 (the two middle numbers) divided by 2 yielding the result of 5.5.

You may wish to visit:


for more information about the median and other statistical measures.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top