C Program to Print Grade Based on Percentage

Write C Program to Print Grade Based on the Percentage

//WAP to print the grade based on the percentage

#include <stdio.h>

int main()
{
float Percentage;

printf("Enter the percentage :--> ");
scanf("%f", &Percentage);

if(Percentage < 33.0)
{
printf("Oops! You are failed");
}
else if(Percentage >= 33.0 & Percentage <= 40.0)
{
printf("Congratulation! You have passed the exam with D Grade");
}
else if(Percentage >= 41.0 & Percentage <= 50.0)
{
printf("Congratulation! You have passed the exam with C2 Grade");
}
else if(Percentage >= 51.0 & Percentage <= 60.0)
{
printf("Congratulation! You have passed the exam with C1 Grade");
}
else if(Percentage >= 61.0 & Percentage <= 70.0)
{
printf("Congratulation! You have passed the exam with B2 Grade");
}
else if(Percentage >= 71.0 & Percentage <= 80.0)
{
printf("Congratulation! You have passed the exam with B1 Grade");
}
else if(Percentage >= 81.0 & Percentage <= 90.0)
{
printf("Congratulation! You have passed the exam with A2 Grade");
}
else if(Percentage >= 91.0 & Percentage <= 100.0)
{
printf("Congratulation! You have passed the exam with A1 Grade");
}
else
{
printf("Please Enter the percentage in the range of 0 to 100");
}

return 0;

}

Output:

Run 1:
Enter the percentage :--> 69.9
Congratulation! You have passed the exam having B2 Grade

Run 2:
Enter the percentage :--> 23.26
Oops! You are failed

Run 3:
Enter the percentage :--> 89.98
Congratulation! You have passed the exam having A2 Grade

Run 4:
Enter the percentage :--> 121
Please Enter the percentage in the range of 0 to 100