Write a program for a school grading system in C

Heya! 👋 I love helping people, and one of the best ways I do this is by sharing my knowledge and experiences. My journey reflects the power of growth and transformation, and I’m here to document and share it with you.
I started as a pharmacist, practicing at a tertiary hospital in the Northern Region of Ghana. There, I saw firsthand the challenges in healthcare delivery and became fascinated by how technology could offer solutions. This sparked my interest in digital health, a field I believe holds the key to revolutionizing healthcare.
Determined to contribute, I taught myself programming, mastering tools like HTML, CSS, JavaScript, React, PHP, and more. But I craved deeper knowledge and practical experience. That’s when I joined the ALX Software Engineering program, which became a turning point. Spending over 70 hours a week learning, coding, and collaborating, I transitioned fully into tech.
Today, I am a Software Engineer and Digital Health Solutions Architect, building and contributing to innovative digital health solutions. I combine my healthcare expertise with technical skills to create impactful tools that solve real-world problems in health delivery.
Imposter syndrome has been part of my journey, but I’ve learned to embrace it as a sign of growth. Livestreaming my learning process, receiving feedback, and building in public have been crucial in overcoming self-doubt. Each experience has strengthened my belief in showing up, staying consistent, and growing through challenges.
Through this platform, I document my lessons, challenges, and successes to inspire and guide others—whether you’re transitioning careers, exploring digital health, or diving into software development.
I believe in accountability and the value of shared growth. Your feedback keeps me grounded and motivated to continue this journey. Let’s connect, learn, and grow together! 🚀
During a peer learning day discussion amongst myself and my colleagues in the ALX Software Engineering (May 2022 cohort), we tasked ourselves with this project to help us understand the implementation of conditional statements in C programming.
The question was:
A school has approached you to develop a program in C that will help them determine the grades for their student based on their score in each examination. Below is a table of the ranges and respective grades
| Range of scores | Grade |
|---|---|
| 80 - 100 | A |
| 70 - 79 | B |
| 65 - 69 | C |
| 60 - 64 | D |
| 50 - 59 | E |
| Below 40 | F |
With just your basic knowledge in C, write a program that solves this problem for them: a. using if statements b. using switch statements
We met as a group to discuss conditional statements including if and switch to enable us solve this problem. Here is a link to the recorded session of our group discussion. You can watch it to understand the solution presented below in details.
Here are the solutions.
Using if statements to make a grading system
#include <stdio.h>
/**
* main - solving our assignment
* description - A program for school grading system
* 80 - 100 == A
* 70 - 79 == B
* 65 - 69 == C
* 60 - 64 == D
* 50 - 59 == E
* Below 50 == F
* return 0
*/
int main(void) {
int score;
/* Tell your user to type their score */
printf("What was your score:\n");
/* Accept the user's input */
scanf("%d", &score);
/* check if the score is between 80 and 100 then print the
* grade if it is
*/
if (score >= 80 && score <= 100 )
{
printf("A");
}
/* check if the score is between 70 and 79 then print the
* grade if it is
*/
else if (score >= 70 && score <= 79 )
{
printf("B");
}
/* check if the score is between 65 and 69 then print the
* grade if it is
*/
else if (score >= 65 && score <= 69)
{
printf("C");
}
/* check if the score is between 60 and 64 then print the
* grade if it is
*/
else if (score >= 60 && score <=64)
{
printf("D");
}
/* check if the score is between 50 and 59 then print the
* grade if it is
*/
else if (score >= 50 && score <= 59)
printf("E");
/* check if the score is below 50 then print the
* grade if it is
*/
else if (score >= 0 && score <= 50)
{
printf("F");
}
else
{
printf("You entered an invalid score");
}
return 0;
}
Using switch statements to make a grading system
#include <stdio.h>
/**
* main - solving our assignment
* description - A program for school grading system
* 80 - 100 == A
* 70 - 79 == B
* 65 - 69 == C
* 60 - 64 == D
* 50 - 59 == E
* Below 50 == F
* return 0
*/
int main(void) {
int score;
/* Tell your user to type their score */
printf("What was your score:\n");
/* Accept the user's input */
scanf("%d", &score);
switch (score)
{
case 80 ... 100:
printf("A \n");
break;
case 70 ... 79:
printf("B \n");
break;
case 65 ... 69:
printf("C \n");
break;
case 60 ... 64:
printf("D \n");
break;
case 50 ... 59:
printf("E \n");
break;
case 0 ... 49:
printf("F \n");
break;
default:
printf("Invalid score");
break;
}
return 0;
}