Ask Question
28 April, 19:19

Whats the error in this code?

/ / This program uses an if/else if statement to assign a

/ / letter grade (A, B, C, D, or F) to a numeric test score.

#include

using namespace std;

int main ()

{

int testScore;

cout << "Enter your test score and I will tell you/n";

cout << "the letter grade you earned: ";

cin >> testScore;

if (testScore < 60)

cout << "Your grade is F./n";

else if (testScore < 70)

cout << "Your grade is D./n";

else if (testScore < 80)

cout << "Your grade is C./n";

else if (testScore < 90)

cout << "Your grade is B./n";

else

cout << "That is not a valid score./n";

else if (testScore < = 100)

cout << "Your grade is A./n";

return 0;

}

+3
Answers (1)
  1. 28 April, 22:45
    0
    if else statements need brackets

    if (condition) {

    //code to execute

    }

    and the include header needs to include something

    #include

    I think that's it

    I could be entirely wrong tho, as I don't actually code in C++. Don't treat this as fact/correct. This is just a guess.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Whats the error in this code? / / This program uses an if/else if statement to assign a / / letter grade (A, B, C, D, or F) to a numeric ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers