Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- FILE *inp,*out;
- int status,r=0,c=0,stu_id,size;
- double quiz[50][5],sum_stu=0,sum_quiz = 0;
- inp = fopen("grades.txt","r");
- if(inp == NULL) printf("YUUH");
- else{
- out = fopen("average.txt","w");
- status = fscanf(inp,"%d",&stu_id);
- while(status != EOF)
- {
- for(c =0; c<5; c++)
- {
- fscanf(inp,"%lf",&quiz[r][c]);
- sum_stu += quiz[r][c];
- }//for
- fprintf(out,"%d %.1f\n",stu_id, sum_stu/5);
- r++;
- status = fscanf(inp,"%d",&stu_id);
- }//while
- size = r;
- printf("Quiz Number Average\n");
- for(c = 0; c<5; c++){
- for(r = 0; r<size; r++){
- sum_quiz += quiz[r][c];
- }
- printf("%d %.2f\n", c+1, sum_quiz/size);
- }//for
- }//else
- fclose(inp);
- fclose(out);
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement