Start New Discussion within our Software Development Community

Hello, I am having trouble understanding why I'm getting these errors.

a4.c:106: error: expected expression before ‘int’
a4.c:106: error: too few arguments to function ‘ass_average’
a4.c:109: error: expected expression before ‘int’
a4.c:109: error: too few arguments to function ‘ass_min’
a4.c:112: error: expected expression before ‘int’
a4.c:112: error: too few arguments to function ‘ass_max’

The error happens here:

for (j=0; j<num_assignments; j++)
101     {
102     printf("==============\n");
103     printf("Ass # %d stats\n", j);
104     printf("==============\n");
106     avg = ass_average(int num_students, int j);
107     printf("  avg = %f\n", avg);
109     min = ass_min(int num_students, int j);
110     printf("  min = %d\n", min);
112     max = ass_max(int num_students, int j);
113     printf("  max = %d\n", max);
114     }

The function prototypes are defined here:

50 int main (int argc, char *argv[])
 51 {
 52     double ass_average(int num_students, int j);
 53     double ass_min(int num_students, int j);
 54     double ass_max(int num_students, int j);

And an example of one of the functions I am calling:

22 double ass_min(int num_students, int j)
 23 {
 24     int i=0;
 25     double current_min=100;
 27     for (i=0; i<num_students; i++);
 28     {
 29     if (grades[i][j] < current_min)
 30     current_min = grades[i][j];
 31     }
 33 return current_min;
 34 }

Do you see anything wrong with this? I've spent a very long time trying to fix it with no luck, I'd greatly appreciate some more experienced insight.

Hopefully I can return the favour one day!

>>avg = ass_average(int num_students, int j);

When you call a function you do not put the variable types as part of the parameters. That's only for function prototypes. All you have to do it put the variable names as the parameters, like this

avg = ass_average(num_students, j);

Thank you for such a quick replay, that fixed it!
This question has already been answered. Start a new discussion instead.