Answer to Question #143336 in C++ for Yvee

Question #143336
Write a function declaration for a function called grader that takes a numeric score and returns a letter grade. Grade has one argument of type integer. Use the rule that 90 to 100 is an A, 80 to 89 is a B, 70 to 79 is a C and less than 70 is an F. (20 points)
1
Expert's answer
2020-11-09T13:09:04-0500
#include <stdio.h>

char grade(int number);

int main() {
    int g;
    printf("Enter a numeric g:  ");
    scanf_s("%d", &g);

    printf("The letter g is %c.\n", grade(g));
    return 0;
}

char grade(int number) {
    if (number >= 90) {
        return 'A';
    } else if (number >= 80) {
        return 'B';
    } else if (number >= 70) {
        return 'C';
    } else if (number >= 60) {
        return 'D';
    } else {
        return 'F';
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog