I'm trying to store 3 sets of 5 double numbers from user input. I need to store the information in a 3 x 5 array and compute the average of each set of five values.
I can't figure out how to fix two errors.
First error: hw9.c:27:2 error: incompatible type for argument 1 of 'set_average' set_average (array[ROW][COL]); ^
Second error: hw9.c:8:6: note: expected 'double (*)[5]' but argument is of type 'double' void set_average(double array[ROW][COL]);
Thanks for any help and suggestions.
#include <stdio.h>
#define ROW 3
#define COL 5
void set_average(double array[ROW][COL]);
void all_average(double array[ROW][COL]);
void find_largest(double array[ROW][COL]);
int main(void)
{
double array[ROW][COL];
int i, j;
printf("Enter three sets of five double numbers.\n");
for (i = 0; i < 3; i++)
for (j = 0; j < 5; j++)
{
printf("Enter elements until done.\n");
printf("Enter %d%d: ",i+1,j+1);
scanf("%le", &array[i][j]);
}
printf("Done entering numbers.\n");
printf("Now it's time to compute the average of each set of five values\n");
set_average (array[ROW][COL]);
return 0;
}
void set_average(double array[ROW][COL])
{
int r; //row
int c;
double sum;
double avg; //average
for (r = 0; r < ROW; r++)
for (c = 0; c < COL; c++)
{
sum += array[r][c];
}
avg = sum / 5;
printf("The average is %le\n", avg);
}