Median number?

How do I get the median (middle) number of three numbers? (C++)

For example;
- User enters the following three numbers; 3, 1, 7
- Program comes up with the minimum, medium, and maximum number of those three numbers.

Enter three numbers: 3 1 7

Minimum number: 1
Middle number: 3
Maximum number: 7


Keep it simple.
Last edited on
First sort the sequence, then apply:

Median for an odd sequence of numbers,
Median = middle element

For an even numbered sequence,
median = [(n/2)th element + [(n/2)+1]th element]/2
Topic archived. No new replies allowed.