So in this C code the program will give an error message that says "Invalid grade" and it asks the user to enter the grade again if the entered grade is >100 or <0, but this only happens once. If the user enters an invalid grade again the program returns black rather than giving the error message again and asking user to reenter the grade. How can I fix this?
#include <stdio.h>
#include <math.h>
int main()
{
double grade;
printf("Enter the student's grade: ");
scanf("%lf",&grade);
if (grade<0 || grade>100)
{
printf("Invalid grade\n");
printf("Enter the student's grade: ");
scanf("%lf", &grade);
}
if (grade>=90 && grade<=100)
printf("A");
if (grade>=80 && grade<=89)
printf("B");
if (grade>=70 && grade<=79)
printf("C");
if (grade>=60 && grade<=69)
printf("D");
if (grade<60 && grade>=0)
printf("F");
return 0;
}