Home »
C solved programs »
C basic programs
C program to read the grade of student print equivalent description
Here, we are going to learn how to read the grade of student print equivalent description using C program?
Submitted by Nidhi, on August 27, 2021
Problem statement
Read the grade of the student from the user, and print an equivalent message.
C program to read the grade of student print equivalent description
The source code to read a grade of student print equivalent description is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.
// C program to read a grade of student and
// print equivalent description
#include <stdio.h>
int main()
{
char grade = 0;
printf("Enter Grade: ");
scanf("%c", &grade);
switch (grade) {
case 'a':
case 'A':
printf("Excellent");
break;
case 'b':
case 'B':
printf("Very Good");
break;
case 'c':
case 'C':
printf("Good");
break;
case 'y':
case 'Y':
printf("You are absent");
break;
case 'f':
case 'F':
printf("You are failed");
break;
default:
printf("Invalid grade");
break;
}
return 0;
}
Output
Enter Grade: A
Excellent
Explanation
Here, we created a variable grade of character type, and read the value of the grade variable and print the appropriate message on the screen.
C Basic Programs »