Please note global variables are not allowed to use in this assignment except of global constants. Find Median. In statistics, the median of a set of values is the value that lies in the middle when...


Please note global variables are not allowed to use in this assignment except of global constants.






 Find Median.
In statistics, the median of a set of values is the value that lies in the middle when the values are arranged in sorted order. If the set has an even number of values, then the median is taken to be the average of the two middle values. Write a C++ program that determines the median of a sorted array. In the main function,



  • Declare and initialize two arrays. One array must contain an even number of values, for example {91, 71, 67, 78, 76, 82, 100, 89}. The other array must contain an odd number of values, for example {76, 71, 78, 67, 82}.

  • Call a function named
    sortArray
    to sort the values in each array in ascending order. should take an array of numbers and an integer indicating the size of the array as the arguments, and sort the array in ascending order. This function does not return any value.

  • Call another function named
    findMedian
    to find the median of the values in each sorted array. The function should take an array of numbers and an integer indicating the size of the array and return the median of the values in the array.

  • At the end, in the main function, the program should display the sorted arrays, number of elements in the arrays, and the medians of the arrays. For example, the outputs could be:


Array numSet1 after sorting is: 67  71  76  78  82  89  91  100


It has 8 values, the median of those values is: 80


Array numSet2 after sorting is: 67  71  76  78  82


It has 5 values, the median of those values is: 76




Note: In this program, you should define two functions:  sortArray, and findMedian as required. You may use the sample code in selection sort example to define sortArray function.



 Debug and test your program to make sure there is no syntax and logical errors. Generate a testing report that includes at least two testing cases and testing results.

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here