97.8k views
2 votes
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\\";
cout << "the letter grade you earned: ";
cin >> testScore;
if (testScore < 60)
cout << "Your grade is F.\\";
else if (testScore < 70)
cout << "Your grade is D.\\";
else if (testScore < 80)
cout << "Your grade is C.\\";
else if (testScore < 90)
cout << "Your grade is B.\\";
else
cout << "That is not a valid score.\\";
else if (testScore <= 100)
cout << "Your grade is A.\\";
return 0;
}

User Furykid
by
5.9k points

1 Answer

3 votes

if else statements need brackets

if(condition) {

//code to execute

}


and the include header needs to include something

#include <iostream>

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.

User Otavio
by
6.1k points