Can someone help me? I can't figure out where its wrong with. The program stops working if I change the 'n' to 'r' in for but if its 'n' it works just fine but there aren't any digits/results that appear.
include
float avg;
float t1[5],t2[5],t3[5],h1[5],h2[5],h3[5],h4[5],pj[5];
float t[5],h[5],prj[5],mark[5],sum=0;
char *grade[10], *overall;
char a[10];
int n,r;
int student[10];
int Ap=0,A=0,Am=0,Bp=0,B=0,Bm=0,Cp=0,C=0,Cm=0,F=0;
for (r=1;r<=68;++r){
fscanf(f1,"%f%f%f%f%f%f%f%f\n",&t1[r],&t2[r],&t3[r],&h1[r],&h2[r],&h3[r],&h4[r],&pj[r]);
t[r]=(t1[r]+t2[r]+t3[r])*20/100;
h[r]=(h1[r]+h2[r]+h3[r]+h4[r])*10/40;
prj[r]=pj[r]*30/100;
mark[r]=t[r]+h[r]+prj[r];
sum= sum+mark[r];
}
for (r=1;r<=68;++r)
if (mark[r]>=90){
grade[r]="A+";
Ap+=1;
}
else if (mark[r]>=80){
grade[r]="A";
A+=1;
}
else if (mark[r]>=70){
grade[r]="A-";
Am+=1;
for (r=1;r<=68;++r)
{
student[r]=r;
printf(" %3d Student%3d ID%3d %.1f %3s\n",student[r],student[r],student[r],mark[student[r]],grade[student[r]]);
}
printf("\nGrade Distribution of the Students : \n");
printf("\nA+ : %d \n",Ap);
printf("\nA : %d \n",A);
printf("\nA- : %d \n",Am);
}
Aucun commentaire:
Enregistrer un commentaire