So I'm at the end of my program. I'm just trying to finish my function that gets the median of an assortment of integers.
Im just having trouble because it comes back with a very bad number, something like -160008897 and I know it has something to do with my array notation in my formula. Can someone just help me spot it? Let me know if you need the whole program, its long.
void getMedian( int *students, int num_students)
{
double median;
if(num_students % 2 !=0)
{
median= ((students[num_students]/2) + ((students[num_students]/2) -students[num_students-1])) / 2;
cout<< "The median of the students surveyed is: "<< median<<endl;
}
else
{
median= students[num_students] / 2;
cout<< "The median of the students surveyed is: "<<median<<endl;
}
}