22.1k views
3 votes
What will the following segment of code output?

Assume the user enters a grade of 90 from the keyboard.
cout << "Enter a test score: ";
cin >> test_score;
if (test_score < 60);
cout << "You failed the test!" << endl;
if (test_score > 60)
cout << "You passed the test!" << endl;
else
cout << "You need to study for the next test!";

User Saad Anees
by
6.1k points

1 Answer

0 votes

Answer:

"You passed the test!"

Step-by-step explanation:

Here user reading grade "test_score" and checking the student score in "If" condition. If it is less than 60 we are printing "You failed the test!" and if it is >60 we are outputting the string "You passed the test!" and else if it not satisfying any of these then we are printing "You need to study for the next test!".As "test_score" value is 90 which is >60 it satisfies the condition >60. So we are printing the string "You passed the test!"

User Davidfurber
by
6.0k points