4.3k views
4 votes
Which value can be entered to cause the following code segment to display the message

"That number is acceptable"?
int number;
cin >> number;
if (number > 10 && number < 100)
cout << "That number is acceptable.\\";
else
cout << "That number is not acceptable.\\";
a. 100
b. 10
c. 99
d. 0
e. all of these

User ZarX
by
7.0k points

1 Answer

1 vote

Final answer:

The correct value to be entered to make the code display 'That number is acceptable' is (c) 99, since 99 is greater than 10 and less than 100, thereby satisfying the conditional statement in the C++ code.

Step-by-step explanation:

The code given is written in C++ and checks if a given number is within a specific range. The conditional statement if (number > 10 && number < 100) is used to check if the entered number is greater than 10 and less than 100. If both conditions are true, the program outputs "That number is acceptable." Based on the options provided:

  • (a) 100 is not acceptable because it is not less than 100.
  • (b) 10 is not acceptable because it is not greater than 10.
  • (c) 99 is acceptable because it meets both conditions: it is more than 10 and less than 100.
  • (d) 0 is not acceptable because it is not greater than 10.
  • (e) Not all of these numbers are acceptable for the reasons given above.

Therefore, the correct answer is (c) 99, which will make the program display "That number is acceptable."

User Thorsten Hans
by
7.5k points