2 C Errors Incompatible type and expected type -


this question has answer here:

i'm trying store 3 sets of 5 double numbers user input. need store information in 3 x 5 array , compute average of each set of 5 values.

i can't figure out how fix 2 errors.

first error: hw9.c:27:2 error: incompatible type argument 1 of 'set_average' set_average (array[row][col]); ^

second error: hw9.c:8:6: note: expected 'double (*)[5]' argument of type 'double' void set_average(double array[row][col]);

thanks , 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 3 sets of 5 double numbers.\n");     (i = 0; < 3; i++)         (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 compute average of each set of 5 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         (r = 0; r < row; r++)             (c = 0; c < col; c++)             {                 sum += array[r][c];             }     avg = sum / 5;     printf("the average %le\n", avg); } 

you calling function as

set_average (array[row][col]); 

instead of

set_average (array); 

function defined void set_average(double array[row][col]) expects array of row. each has array of col items doubles. error reported because function called 1 double argument.


Popular posts from this blog