63.6k views
3 votes
What will the following segment of code output? You can assume the user enters a grade of 90 from the keyboard. a. You failed the test! b. You passed the test! c. You did poorly on the test! d. None of these

User MattSkala
by
5.3k points

1 Answer

1 vote

COMPLETE QUESTION:

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!";

A) You failed the test!

B) You passed the test!

C) You did poorly on the test!

D) None of the above

Answer:

B) You passed the test!

Step-by-step explanation:

The code above prompts a user to enter an integer value, Using a combination of if and else statements, it checks if the integer entered by the user is less than 60, if it is it will printout You failed the test. But if the integer test_score is greater than 60, it prints You passed the test!.. In the example we entered the integer 90 which is greater than 60, so the output is as expected You passed the test!

User Rafalon
by
6.2k points