Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm having trouble with this assignment. This is the code I have so far. Thank you. #include using namespace std; int main() { int* grades

image text in transcribed

I'm having trouble with this assignment. This is the code I have so far. Thank you.

#include

using namespace std;

int main()

{

int* grades = nullptr;

int nGrades = 0;

double median;

cout

cin >> nGrades;

grades = new int[nGrades];

for(int i=0;i

{

cout

cin >> *(grades+1);

}

int total = 0;

for (int i = 0; i

{

total += *(grades+1);

}

if(nGrades%2==1)

{

median = (double)*(grades+(nGrades/2));

}

median = (double)(*(grades+(nGrades/2))+*(grades+(nGrades/2)))/2;

cout

}

Skill Practice Assignment 2 - Median Function Median Function: 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 teh array are already sorted.) Please use pointer notation rather than array notation in solving this problem. In order to assure us of using the same even and odd arrays, please use the following in your assignment // An array with an odd number of elements int odd[] = { 1, 2, 3, 4, 5, 6, 7}; II An array with an even number of elements int even[] = { 1, 2, 3, 4, 5, 6, 7, 8 }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

3. Where is the job to be accomplished?

Answered: 1 week ago

Question

=+How will this affect the recruiting process?

Answered: 1 week ago