In statistics, when a set of values is sorted in ascending or descending order,
ID: 3774562 • Letter: I
Question
In statistics, when a set of values is sorted in ascending or descending order, its median is the middle value. If the set contains an even number of values, the median is the mean, or average, of the two middle values. Write a function that accepts as arguments the following: a. An array of integers b. An integer that indicates the number of elements in the array The function should determine the median of the array. This value should be returned as a double. (Assume the values in the array are already sorted.) You’ll create two arrays: one with three elements (e.g. 1, 3, 7) and one with four elements (e.g. 2, 4, 5, 8). Demonstrate your pointer prowess by using pointer notation instead of array notation in this function.
Explanation / Answer
#include using namespace std; char again; int getMedian(double*, int); const int constant = 100; int main() { do { int number; double *array; int median = 0; cout > number; array = new int[number]; for (int count=0; countRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.