The outline I gave you was general. You need to reset your counters as well. Ok, you know what look at this. NOTE: I did not do percentages for this. I am sure you can figure out that math
Code:
#include <stdio.h>
int main(void)
{
int sCode, studID, m, loop = 0, loopS = 0;
float mark, totalPrint, totalStored, totalSchool=0,averageSection = 0, averageSchool = 0;
printf("\n\nEnter the Section Code: ");
scanf("%d", &sCode);
do{
totalStored = 0;
averageSection = 0;
loop = 0;
loopS++;
while (sCode > 4 || sCode < 1){
printf("Invalid value entered. Must be 1 to 4, please re-enter: ");
scanf("%d", &sCode);
}
printf("Enter the Student's ID: ");
scanf("%d", &studID);
do{
totalPrint = 0;
loop++;
for (m = 1; m < 6; m++){
printf("Enter Mark #%d: ", m);
scanf("%f", &mark);
while (mark > 20 || mark < 0){
printf("Invalid grade entered. Must be 0.0 to 20.0, please re-enter: ");
scanf("%f", &mark);
}
totalPrint = totalPrint + mark;
}
totalStored = totalStored + totalPrint;
printf("%d's total mark is: %.2f\n", studID, totalPrint);
printf("Enter the Student's ID ['0' to quit]: ");
scanf("%d", &studID);
} while (studID != 0);
averageSection = (totalStored / loop);
totalSchool = totalSchool + averageSection;
printf("\nThe average for the section is: %.2f%\n\n", averageSection);
printf("Enter the Section Code ['0' to quit]: ");
scanf("%d", &sCode);
} while (sCode != 0);
averageSchool = (totalSchool / loopS);
printf("\nThe average for the course is: %.2f%\n\n", averageSchool);
return (0);
}