I am trying to get a median from an array of which i do now know how many items are in it. I know I have to sort it, but I do not how to do this to get the median. Here is what I have so far. How do i go about finding the median?
1 2 3 4 5 6 7 8 9 10 11 12 13
int howmany;
int sum = 0;
int grades[100];
cout << "How many grades do you have for Exam 2?"; cout << endl;
cin >> howmany;
cout << "Please enter the grades for Exam 2"; cout << endl;
for (int i = 0; i < howmany; ++i){
cout << "Enter Grade " << i + 1 << ": ";
cin >> grades[i];
sum += grades[i];
} // End For