Question: 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
Get step-by-step solutions from verified subject matter experts
