Help with this question using If statement

Hi guys, There this question that i cannot figure it out please help me.
Q:

Write a program that allows the user to enter a score between 0 and 100 and then print out a letter grade based on the score. Use if statements, and don't forget to test for valid input.

Thanks Appreciate!!
Last edited on
It would look something like this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
using namespace std;

int main(){
    int score;
    
    cout << "Enter score: ";
    cin >> score;
    cout << endl;
    
    if (score >= 90)
        cout << "This is an A." << endl;
    else if (score >= 80)
        cout << "This is a B." << endl;
    else if (score >= 70)
        cout << "This is a C." << endl;
    else
        cout << "Invalid entry." << endl;
    
    return 0;
}
Last edited on
Topic archived. No new replies allowed.