#include<stdio.h>
char convert_percent_to_grade(float input)
{
if(input>=80.0f)
{
return 'A';
}
else if(input>=60.0f && input <80.0f)
{
return 'B';
}
else if(input>=50.0f && input < 60.0f)
{
return 'C';
}
else
{
return 'D';
}
}
int main()
{
float input;
printf("What's the percentage:\n");
scanf("%f",&input);
char output = convert_percent_to_grade(input);
printf("%.2f%% is %c Grade",input,output);
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter