Simple Median hekp

I'm trying to find the median in an array and am stuck at the end of my code, obviously grade[median] isn't showing me the grade in the median location, like i'm trying to do. of course, it gives me an error. So what would be the proper way to make it show me the median location in the array? Also, this will only work correct with an odd number of array elements and I know to find the median in an array of even amount of elements, you take the 2 middle terms then divide by 2. Any help on getting the location for the 2 middle terms and dividing by 2?

ps- I know it needs to be sorted first but that is being taken care of by a different person. My job is to come up with the algorithm for finding the median.

If the sorted sequence has an odd length, take the middle score as the median (length/2). If the length is even, you have to divide the sequence into two parts of equal length, and take the average of the last score in part A and the first score in part B to get the median.

If the sorted sequence has an odd length, take the middle score as the median (length/2). If the length is even, you have to divide the sequence into two parts of equal length, and take the average of the last score in part A and the first score in part B to get the median.

Thank you, but do you know how to display the score in the [median] spot of the array?

Thank you, but do you know how to display the score in the [median] spot of the array?

Once you have found it, you would display it like how you would display any other score.

Originally Posted by Bjarne Stroustrup (2000-10-14)

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.