I have the following code:
#define MIDTERM_PERCENTAGE 40
#define FINAL_PERCENTAGE 60
#define ARRAY_LENGTH(array) (sizeof((array))/sizeof((array)[0]))
struct student
{
char name[20];
int midterm;
int final;
int grade;
}
int calcGrade(struct student s) {
int midterm = (s.midterm * MIDTERM_PERCENTAGE)/100;
int final = (s.final * FINAL_PERCENTAGE)/100;
int grade = midterm + final;
return grade;
}
And I'm getting these errors:
student.c:13: two or more data types in declaration of `calcGrade'
student.c: In function `calcGrade':
student.c:17: incompatible types in return
I do also have a header file that has the following declaration:
int calcGrade(struct student s);
However, I do not see my errors. I thought maybe it was an issue with my division but since it gives me no error on setting grade=midterm+final I don't see why I have an issue with my return type.
You forgot a semicolon after the end of the struct definition.