I have to write a code that uses functions
I have to calculate the median of an array that is inputted by the user,
therefore I have to design a function that sorts the numbers.
So in my median function i need to call on the sort function to get the numbers in order than to determine the median from there to give back to the MAIN program...
I dont even know where to start any help?
this is what I have so far
from the median function and the sort function i am making for my code
+++++
Code:
#include <stdio.h>
#include <math.h>
double median(double a[], int n);
void sort(double a[], int n);
int main (void)
{
int i, w;
med;
printf("Enter the number of elements in the array: ");
scanf("%d", &w);
double a[w];
for(i=0; i <w; i++)
{
printf("Enter element %d: ", i);
scanf("%lf", &a[i]);
}
med = median(a,w);
printf("The median is: %.2f", med);
return 0;
}
double median(double a[], int n)
{
int i=0;
for(i=0; i<n; i++)
{
b[i] = a[i];
}
return median;
}
void sort(double a[], int n)
{
int middle;
}