So I working on a program that in a poin in the program I have to get the median and the average of the numbers in the array.

I have to write a program that will read in a list of positive integers (including zero) and display some statistics regarding the integers.

Help?

first put the list of your numbers in an array.
1. median: get array.size()

if (odd) median=array[size/2-1]   //if size=3 return array[1]
if even median=(array[size/2]+array[size/2-1])/2

2.mean:

int mean;
int sum=0;
for(int i=0; i<array.size(),i++){
sum+=array[i];

}
mean=sum/array.size();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.