I'm pretty new to C and I have encountered a problem. In my code, I want to get the age, gpa, and letter grade of the user. However, when I run the code, it only gets the inputs for the age and gpa, ignoring the letter grade. It only asks for 2 inputs all in all instead of 3. But if I were to individually check for inputs instead of simultaneously doing so, it functions correctly. Why is this happening?
Check my code below:
int main(void) {
  int age;
  double gpa;
  char grade;
  // int
  printf("Enter your age: ");
  scanf("%d", &age);
  // double
  printf("Enter your gpa: ");
  scanf("%lf", &gpa);
  // char
  printf("Enter your letter grade: ");
  scanf("%c", &grade);
  // prints
  printf("You are %d years old", age);
  printf("\nYour gpa is %f", gpa);
  printf("\nYour grade is %c", grade);
  return 0;
}
OUTPUT:
Enter your age: 12
Enter your gpa: 4.0
Enter your letter grade: You are 12 years old
Your gpa is 4.000000
Your grade is
 
     
    