Ask 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 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;

}

+4
Answers (1)
  1. 9 July, 13:59
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers