#include <stdio.h>
char calcLetterGrade(int score);
int main(void)
{
int score = 85;
char LetterGrade = calcLetterGrade(score);
return 0;
}
char calcLetterGrade(int score) // Corrected function definition
{
char result; //* letter grade result */
if (score > 100 || score < 0) // check for invalid score
return 'I';
// Map score to letter grade
if (score >= 90 && score <= 100) // 90-100 is an A
result = 'A';
else if (score >= 80 && score <= 89) // 80-89 is a B
result = 'B';
else if (score >= 70 && score <= 79) // 70-79 is a C
result = 'C';
else if (score >= 61 && score <= 69) // 61-69 is a D
result = 'D';
else
result = 'F'; // any other results passed through are fails as invalids were caught
return result;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgpjaGFyIGNhbGNMZXR0ZXJHcmFkZShpbnQgc2NvcmUpOwoKaW50IG1haW4odm9pZCkgCnsKICAgIGludCBzY29yZSA9IDg1OwogICAgY2hhciBMZXR0ZXJHcmFkZSA9IGNhbGNMZXR0ZXJHcmFkZShzY29yZSk7CiAgICBwcmludGYoIiVjXG4iLCBMZXR0ZXJHcmFkZSk7CgogICAgcmV0dXJuIDA7Cn0KCmNoYXIgY2FsY0xldHRlckdyYWRlKGludCBzY29yZSkgLy8gQ29ycmVjdGVkIGZ1bmN0aW9uIGRlZmluaXRpb24KewogICAgY2hhciByZXN1bHQ7IC8vKiBsZXR0ZXIgZ3JhZGUgcmVzdWx0ICovCgoKICAgIGlmIChzY29yZSA+IDEwMCB8fCBzY29yZSA8IDApCQkvLyBjaGVjayBmb3IgaW52YWxpZCBzY29yZQogICAgICAgIHJldHVybiAnSSc7CgogICAgLy8gTWFwIHNjb3JlIHRvIGxldHRlciBncmFkZQogICAgaWYgKHNjb3JlID49IDkwICYmIHNjb3JlIDw9IDEwMCkJLy8gOTAtMTAwIGlzIGFuIEEKICAgICAgICByZXN1bHQgPSAnQSc7CiAgICBlbHNlIGlmIChzY29yZSA+PSA4MCAmJiBzY29yZSA8PSA4OSkgLy8gODAtODkgaXMgYSBCCiAgICAgICAgcmVzdWx0ID0gJ0InOwogICAgZWxzZSB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