Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So I wrote this code however I cant figure out 1 simple thing.For some reason my code wont give me the median from the even

So I wrote this code however I cant figure out 1 simple thing.For some reason my code wont give me the median from the even array it should equal 4.5 however my code wont go through and give me that answer please help me to display the median of the even array

// ConsoleApplication4.cpp : This file contains the 'main' function. Program execution begins and ends there.

//

#include

#include

using namespace std;

double median(int *array, int size)

{

float Midpoint;// defining it so I can pass variables to different functions

if (size % 2 == 0)// to define the even and odd

{

Midpoint = size / 2;// stops halfway throgh the function

}

else

{

Midpoint = (size / 2 + 1);

}

return Midpoint;

}

void displayArray(int *array, int size)// simply displays the array also using a for loop

{

for (int i = 0; i < size; i++)

{

cout << array[i];

}

cout << " ";

}

int main()

{

int array2[8] = { 1,2,3,4,5,6,7,8};

int array1[7] = {1,2,3,4,5,6,7}; cout << "The odd number value array ="<

}

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

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions