Dsa
Math
Easy
Mean and Median Calculator
Write a program that takes a list of integers and computes the mean and the median. The mean is the average of the numbers, and the median is the middle value when the numbers are sorted. If there is an even number of values, the median should be the average of the two middle values.
Input Format:
- The first line contains an integer n (1 ≤ n ≤ 10^5), the number of integers in the list.
- The second line contains n space-separated integers.
Output Format:
- Print the mean and the median, rounded to two decimal places, separated by a space.
Example:
Input:
5
1 3 3 6 7
Output:
4.00 3.00
Key concepts
statisticsmeanmedian
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now