Ask Question
18 March, 21:20

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;

}

+2
Answers (1)
  1. 18 March, 22:10
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers