Write a program that takes as input a class score. Output the grade for the class based on the
following guideline:
Exactly 100 is A+
90and above is A
80 and above is B
70 and above is C
60 and above is D
Anything less than 60 is F
Anything more than 100 or less than 0 is invalid input.
#include <stdio.h>
void main(){
int score;
printf("Enter score[0-100]: ");
scanf("%d",&score);
if (score==100){
printf("Grade: A+\n");
}
else if (score >= 90 && score < 100)
{
printf("Grade: A\n");
}
else if (score >= 80 && score <= 89)
{
printf("Grade: B\n");
}
else if (score >= 70 && score <= 79)
{
printf("Grade: C\n");
}
else if (score >= 60 && score <= 69)
{
printf("Grade: D\n");
}
else if (score >= 0 && score <= 59)
{
printf("Grade: F\n");
}else{
printf("Invalid input.\n");
}
scanf("%d",&score);
}
Comments
Leave a comment