Automating Student Success: A C Program for School Grading System

Introduction:

In this blog, we will be discussing a C program that implements a school grading system. This program takes the score of a student and outputs their grade and a message based on the range of their score.

Let's look at the code,

The Code

#include <stdio.h>

/**

* main - My first project for grading system

* description - A program for a school grading system

*/

int main()

{

int score;

printf("Enter your score ");

scanf("%d", &score);

if (score >= 80 && score <= 100)

{

printf("Your grade is A\n");

if (score = 80 && score <= 85)

printf("You are an excellent student");

else

printf("You got distinction");

}

else if (score >= 70 && score <= 79)

{

printf("Your grade is B");

}

else if (score >= 65 && score <= 70)

{

printf("Your grade is C");

}

else if (score >= 60 && score <= 64)

{

printf("Your grade is D");

}

else if (score >= 50 && score <= 59)

{

printf("Your grade is E");

}

else if (score < 40)

{

printf("You have Failed");

}

else

{

printf("You have entered an invalid score");

}

return (0);

}

Program Description:

The program starts with the declaration of an integer variable called "score". It then prompts the user to enter their score using the printf() function and reads the input using the scanf() function.

The program then checks the score entered by the user and uses a series of if-else statements to determine the grade of the student. If the score is between 80 and 100, the program will output "Your grade is A" and check whether the student scored between 80 and 85. If so, the program will output "You are an excellent student", otherwise it will output "You got distinction". Similarly, if the score is between 70 and 79, the program will output "Your grade is B". If the score is between 65 and 70, the program will output "Your grade is C". If the score is between 60 and 64, the program will output "Your grade is D". If the score is between 50 and 59, the program will output "Your grade is E". Finally, if the score is less than 40, the program will output "You Have Failed".

If the score entered by the user is not within the valid range, the program will output "You have entered an invalid score".

Conclusion:

In conclusion, this C program implements a school grading system that takes the score of a student and outputs their grade and a message based on the range of their score. The program uses a series of if-else statements to determine the grade of the student and provide an appropriate message. This program can be useful for schools or educational institutions to automate the grading process and provide consistent feedback to students.