I have an input data file called "TEST.txt". it contains id numbers, names, grades of three different exams of ten students. I'm trying to make a program that reads these input data, calculates the mean value of exams for each student, and writes again id numbers,names, averages, of students whose averages are >=45.5 into output file called "RESULT.TXT" using structures. I think I am able to read my input data with the structure I defined. I want to know what can I do for finding the averages of exams (one,two, and three), setting the condition of writing average values, and writing ids,names, and averages into RESULTS.TXT. Here is my code until now.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 typedef struct student{
    char name[30];
    int id;
    int exam1;
    int exam2;
    int exam3;
}STUDENT;
int main(){
    int sum=0;
    int i=0;
    double mean[10];
    STUDENT test[10]; 
    FILE *fRead;
    fRead=fopen("TEST.txt","r+");
    if((fRead=fopen("TEST.txt","r"))==NULL){
        printf("File could not be opened\n");       
    }
    while(!feof(fRead)){
            fscanf(fRead,"%d%s%d%d%d",&(test[i].id),test[i].name,&(test[i].exam1),&(test[i].exam2),&(test[i].exam3));
            printf("\n%s\n",test[i].name);
            i++;    
    }
    return 0;
}
				
                        
the following code:
feof()and now the code