English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Consider this informal description of some instructions:
if ( __________________ )
document.write(aNumber is between 1 and 10 inclusive)
else
document.write(aNumber is less than 1 or greater than 10)
Which of the following Boolean conditions would be most appropriate for
testing the value of aNumber? You can assume that aNumber has been
properly declared and holds an integer value.
1) (aNumber >= 1) || (aNumber <= 10)
2) (aNumber < 1) || (aNumber > 10)
3) (aNumber >= 1) && (aNumber <= 10)
4) (aNumber >1) && (aNumber < 10)

2007-09-15 02:48:19 · 2 answers · asked by ssmlrm 1 in Computers & Internet Programming & Design

2 answers

if (aNumber >= 1) && (aNumber <= 10)
 document.write(aNumber is between 1 and 10 inclusive)
else
 document.write(aNumber is less than 1 or greater than 10)

2007-09-15 02:53:23 · answer #1 · answered by Andy 3 · 0 0

Andrew: you forgot the parenthesis:

if "(" (aNumber >= 1) && (aNumber <= 10) ")"

But you should not do student's homework: only guide them!
Giving the answer make them pass their homework, but will certainly fail them at their exams... Is that what you want?

2007-09-15 12:48:10 · answer #2 · answered by just "JR" 7 · 0 0

fedest.com, questions and answers