It was challenging to word the title for this question, but I hope you can forgive me as I will elaborate here. The problem i'm having is my C program floods the console with "Enter the student's grade: F" if I enter anything other than an integer. I'm new to C, so I don't understand how to check if the input is of the valid type.
int main() {
  int grade; //number 0-10 associated with the letter grade
  while (1) {
    printf("Enter the student's grade: ");
    scanf("%i", &grade);
    switch (grade) {
      case 10: printf("A \n"); break;
      case 9: printf("A \n"); break;
      case 8: printf("B \n"); break;
      case 7: printf("C \n"); break;
      case 6: printf("D \n"); break;
      case 5: printf("F \n"); break;
      case 4: printf("F \n"); break;
      case 3: printf("F \n"); break;
      case 2: printf("F \n"); break;
      case 1: printf("F \n"); break;
      case 0: printf("F \n"); break;
      default: printf("Please enter a valid test score \n"); break;
    }
  }
  return 0;
}
Thanks for the help!
 
     
     
    