Saved Bookmarks
| 1. |
Write a program to find the median of n no. of elements in c++ |
|
Answer» Answer: Input : a[] = {1, 3, 4, 2, 6, 5, 8, 7} Output : Mean = 4.5 MEDIAN = 4.5 Sum of the ELEMENTS is 1 + 3 + 4 + 2 + 6 + 5 + 8 + 7 = 36 Mean = 36/8 = 4.5 Since number of elements are EVEN, median is average of 4th and 5th largest elements. which means (4 + 5)/2 = 4.5 Input : a[] = {4, 4, 4, 4, 4} Output : Mean = 4 Median = 4 |
|