The Program in C that calculates the grade of a student when the user puts marks is given below:
#include <stdio.h>
int main() {
int marks;
char grade;
printf("Enter the student's marks: ");
scanf("%d", &marks);
if (marks >= 90) {
grade = 'A';
} else if (marks >= 80) {
grade = 'B';
} else if (marks >= 70) {
grade = 'C';
} else if (marks >= 60) {
grade = 'D';
} else {
grade = 'F';
}
printf("The student's grade is: %c\n", grade);
return 0;
}
Output:
Enter the student’s marks: 93
The student’s grade is: A
Pro-Tips💡
In this program, the user is prompted to enter the student’s marks. The marks are then assigned to the variable marks
.
The program uses if-else statements to determine the student’s grade based on the value of marks
. The grade is then assigned to the variable grade
and printed out to the user.
You can adjust the if-else statements to match your own grading criteria.
Learn C-Sharp ↗
C-sharp covers every topic to learn about C-Sharp thoroughly.
Learn C Programming ↗
C-Programming covers every topic to learn about C-Sharp thoroughly.
Learn C++ Programming↗
C++ covers every topic to learn about C-Sharp thoroughly.