Assignment involving loops, if statements and arrays; program will not run
Hi, my program basically records the grades of 5 students in 3 subjects and prints the results according to total marks, percentage and what that percentage translates to in the form of a letter grade. Also it states the class, roll number, section and of the student. As I said, the program stops working after I try to enter the first value for class. Any help would be greatly appreciated, than you very much for your time.
Code:
#include<stdio.h>
#include<string.h>
int main()
{
float mth[5],bio[5],chem[5],tm[5],p[5];
char name[5][25],sec[5];
int i,c[5],r[5];
for (i=0;i<5;i++)
{
for (i=0;i<5;i++)
{
printf("Please enter your class, role number, section and name: ");
scanf("%d\n%d\n%c\n%s",c[i],r[i],sec[i],name[i]);
}
top:
printf ("Please enter obtained marks for math, biology and chemistry for Student %d: ",i);
scanf ("%f%f%f",&mth[i],&bio[i],&chem[i]);
if ((mth[i]<0)||(mth[i]>100)||(bio[i]<0)||(bio[i]>100)||(chem[i]<0)||(chem[i]>100))
{
printf("Entry error, please try again.");
goto top;
}
tm[i]=(mth[i]+bio[i]+chem[i]);
p[i]=tm[i]/3;
}
for(i=0;i<5;i++)
{
printf("\nTotal Marks: %f\n \nPercent: %f\n",tm[i],p[i]);
if (p[i]>=90)
{
printf("\nLetter Grade: A\n");
}
else if ((p[i]>=80)&&(p[i]<90)) {
printf("\nLetter Grade: B\n");
}
else if ((p[i]>=70)&&(p[i]<80)) {
printf("\nLetter Grade: C\n");
}
else if ((p[i]>=60)&&(p[i]<70)) {
printf("\nLetter Grade: D\n");
}
else {
printf("\nLetter Grade: E\n");
}
}
return 0;
}