I'm not sure if it's called loop stacking but I think it makes sense. Basically I have this program I need to write using ONLY loops. Nothing else. The program has to calculate 5 marks (input by the user), adds the 5 marks and then asks if the user wants another students' 5 marks to be calculated. I got the looping part done I just need help because my program "stacks" the totals of all the students and does not separate them. For example; if student 1's combined 5 marks equals 15, when the program loops and the user enters the marks for the second student it will literally stack onto the total set by the previous student. So instead of having student 2 with a mark of 15 it will be 30 instead. Thanks in advance for the help I know there's a logical answer to this but I can't find it.
Code:
do {
printf("Enter the Student's ID: ");
scanf("%d", &studID);
for (m = 1; m < 6; m++)
{
printf("Enter Mark #%d: ", m);
scanf("%f", &mark);
while (mark > 20)
{
printf("Invalid grade entered. Must be 0.0 to 20.0, please re-enter: ");
scanf("%f", &mark);
}
}
total += mark;
printf("%d's total mark is: %.2f\n", studID, total);
} while (doAgain);