QUESTION IMAGE
Question
practice question #2
the program below asks a user to type in a number and then will output a message. what number will a
to input for the message \cold\ to be displayed?
number <- input()
if (number >= 10)
{
if (number <= 20)
{
display(\medium\)
}
else
{
display(\hot\)
}
}
else
{
display(\cold\)
}
choose one answer:
5 10 15 20
Step1: Analyze the conditions for "COLD"
The message "COLD" is displayed when the condition number < 10 is met.
Step2: Check each option
- For option \(5\): Since \(5<10\), the condition for "COLD" is satisfied.
- For option \(10\): Since \(10 = 10\), the condition
number >= 10is true, so it will check the inner - if. - For option \(15\): Since \(15>=10\) and \(15<=20\), it will display "MEDIUM".
- For option \(20\): Since \(20>=10\) and \(20<=20\), it will display "MEDIUM".
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
\(5\)