I'm trying to write a simple program which receives marks, names and ID's of at most 30 students and prints average of their marks. I was wondering why the result of the program is always zero.
I appreciate if anyone could leave me a hint.
Here is the code:
#include <stdio.h>
struct student{
char name[30];
int mark;
int ID;
} s[30];
int main() {
int n, i=0, sum=0;
float average;
/* printf("enter the number of students: "); */
scanf("%d", &n);
/* printf("enter their information: "); */
for(i=0; i<n; i++)
scanf("%s,%d,%d",s[i].name,&s[i].mark,&s[i].ID);
for(i=0; i<n; i++)
sum+=s[i].mark;
average=sum/(float)n ;
printf("%.2f", average);
}