So my teacher gave us this file
#include <stdio.h>
#define MAXVALS 100 /* max number of values we can process */
int tableFill(double a[], int max);
void tablePrint(double a[], int num);
double tableAverage(double a[], int num);
int tableMatchingElements(double a[], int num, double target);
int main()
{
double table[MAXVALS]; /* array to hold input values */
int n; /* number of values in "table" */
double average; /* average input value */
int equal; /* number of values the same as average */
n = tableFill(table, MAXVALS);
average = tableAverage(table, n);
printf("Average of the %d values read is: %lf\n", n, average);
equal = tableMatchingElements(table, n, average);
printf("There are %d values equal to the average.\n", equal);
printf("The values greater than the average:\n");
tablePrint(table, n);
printf("The values less than the average:\n");
tablePrint(table, n);
}
int tableFill(double a[], int max)
{
double next; /* next input value */
int r; /* return from trying to read values */
int cnt = 0; /* count of values read */
while ((r = scanf("%lf", &next)) != EOF)
{
if (r != 1) /* bad return from scanf */
{
printf("Error in the input after reading %d values.\n",
cnt);
break;
}
if (cnt == max) /* no room to store this value */
{
printf("Array full after reading %d values.\n", cnt);
break;
}
a[cnt++] = next; /* save element in array */
}
return cnt;
}
void tablePrint(double a[], int num)
{
int i;
for (i = 0; i < num; i++)
printf("%f\n", a[i]);
}
double tableAverage(double a[], int num)
{
return 0.0; /* doesn't really compute the average */
}
int tableMatchingElements(double a[], int num, double target)
{
return 0; /* number of values equal to the target */
}
And he wants us to break it into .c and .h files and compile using a makefile to produce an output like this
10 20 30 30 40 50
Average of the 6 values read is: 30.000000
There are 2 values equal to the average.
There are 2 values greater than the average:
40
50
There are 2 values less than the average:
10
20
I already break them down and made the makefile but what functions do I need to fix to produce that output? Please help.