I cant seem to make this work i have an issue when i call the function into main, the data type of the array is NOT compatible...
I know I have to change the pointers or data type, but if i do, i don't get the right median number or the combination is incompatible.
Please help me out, I been trying this little piece of code for more than 3 hours.
Thank you
Code:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define maxarr 30
void show_median(double *[], int counter);
int main ()
{
double arr[maxarr], value;
int counter, i;
counter=0;
scanf("%lf", &value);
while(value !=-1)
{
arr[counter]= value;
printf("Please enter '-1' to stop entering values.\n");
scanf("%lf", &value);
counter=counter+1;
}
printf("values entered are:\n\n");
i=0.0;
while(i<counter)
{
printf("%.1lf ", arr[i]);
i=i+1;
}
show_median(arr, counter);
return 0;
}
void show_median(double *arr[], int counter)
{
int mid;
double median2;
mid=counter/2.0;
if(counter%2)
median2= (*arr[mid]+*arr[mid/+1])/2.0;
else (median2=*arr[mid]);
printf("median is : %.1lf\n", median2);
}