Median and sort

Write a function returns the median
entry in a 1-dimensional array of integers.
if we have an array a={3,4,5,1,6}; then the
median entry of this array a is 4. You need to sort the array
a first, to get {1,3,4,5,6}, then find the entry in the middle
position.
Don't post homework questions
Programmers are good at spotting homework questions; most of us have done them ourselves. Those questions are for you to work out, so that you will learn from the experience. It is OK to ask for hints, but not for entire solutions.
closed account (48T7M4Gy)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>

using namespace std;

int function();

int main()
{
    function();
    
    return 0;
}

int function()
{
    int a[] = {3,4,5,1,6};
    int a_sorted = {1,3,4,5,6};

    int median = 4;
    int integer_in_middle_position = 4;

    return median;
}
Topic archived. No new replies allowed.