#include <stdio.h>
char calcLetterGrade (int num_grade);
int main(void) {
char retValue=calcLetterGrade(2);
printf("The grade is: %c\n", retValue
); return 0;
}
char calcLetterGrade (int num_grade)
{
char letterGrade;
if ( num_grade >= 90 && num_grade <= 100 ){
letterGrade='A';
}
else if ( num_grade >= 80 && num_grade <= 89 ){
letterGrade='B';
}
else if ( num_grade >= 70 && num_grade <= 79 ){
letterGrade='C';
}
else if ( num_grade >= 60 && num_grade <= 69 ){
letterGrade='D';
}
else if ( num_grade >= 0 && num_grade <= 59 ){
letterGrade='F';
}
else if ( num_grade > 100 || num_grade < 0 ){
letterGrade='I';
}
return letterGrade;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CmNoYXIgY2FsY0xldHRlckdyYWRlIChpbnQgbnVtX2dyYWRlKTsKCmludCBtYWluKHZvaWQpIHsKCWNoYXIgcmV0VmFsdWU9Y2FsY0xldHRlckdyYWRlKDIpOwogICAgcHJpbnRmKCJUaGUgZ3JhZGUgaXM6ICVjXG4iLCByZXRWYWx1ZSk7CglyZXR1cm4gMDsKfQoKY2hhciBjYWxjTGV0dGVyR3JhZGUgKGludCBudW1fZ3JhZGUpCnsKICAgY2hhciBsZXR0ZXJHcmFkZTsKICAgIAogICAgaWYgKCBudW1fZ3JhZGUgPj0gOTAgJiYgbnVtX2dyYWRlIDw9IDEwMCApewogICAgICAgIGxldHRlckdyYWRlPSdBJzsKICAgIH0KICAgIGVsc2UgaWYgKCBudW1fZ3JhZGUgPj0gODAgJiYgbnVtX2dyYWRlIDw9IDg5ICl7CiAgICAgICAgbGV0dGVyR3JhZGU9J0InOwogICAgfQogICAgZWxzZSBpZiAoIG51bV9ncmFkZSA+PSA3MCAmJiBudW1fZ3JhZGUgPD0gNzkgKXsKICAgICAgICBsZXR0ZXJHcmFkZT0nQyc7CiAgICB9CiAgICBlbHNlIGlmICggbnVtX2dyYWRlID49IDYwICYmIG51bV9ncmFkZSA8PSA2OSApewogICAgICAgIGxldHRlckdyYWRlPSdEJzsKICAgIH0KICAgIGVsc2UgaWYgKCBudW1fZ3JhZGUgPj0gMCAmJiBudW1fZ3JhZGUgPD0gNTkgKXsKICAgICAgICBsZXR0ZXJHcmFkZT0nRic7CiAgICB9CiAgICBlbHNlIGlmICggbnVtX2dyYWRlID4gMTAwIHx8IG51bV9ncmFkZSA8IDAgKXsKICAgICAgICBsZXR0ZXJHcmFkZT0nSSc7CiAgICB9CiAgICByZXR1cm4gbGV0dGVyR3JhZGU7Cgp9IA==