Ok so I used this site yesterday and it was a great help you guys are amazing but today I ran into another little problem. I have a nested while loop inside a for loop. The while loop is an error message that asks for user input if the input from the for loop was incorrect. The thing is, the incorrect data input by the user will still add onto the total when I do not want it to. For example; 5 students enter their grades out of 20. Student 1 enters 1 Student 2 enters 2 etc...student 3 enters 300 when the user enters 300 for student 3 it does give an error message stating that invalid grade was entered then student 3 enters 3, student 4 enters 4 and student 5 enters 5. The total should be 15 (1+2+3+4+5) but for some reason my program adds the incorrect number input by the user (300) and adds it to my total. Any help would be greatly appreciated, I can't figure this one out.

Code:
do {
  total = 0;
  loop++;
  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 || mark < 0)
    {
      printf("Invalid grade entered. Must be 0.0 to 20.0, please re-enter: ");
      scanf("%f", &mark);
      total = total + mark;
      average = (store / (loop * 100)) * 100;
    }
    store = store + mark;
    total = total + mark;
    average = (store / (loop * 100)) * 100;
  }

  printf("%d's total mark is: %.2f\n", studID, total);
  printf("Enter the Student's ID ['0' to quit]: ");
  scanf("%d", &doAgain);
} while (doAgain);

printf("The average for the section is: %.2f%\n", average);
}