Enter a number ? -5 The number is negative. Bye
ONLY the FALSE branch was executed because the answer to the
question NUMBER >= 0
was FALSE.
Here is the program again with some added statements:
PRINT "Enter a Number" INPUT NUMBER ' IF NUMBER >= 0 THEN PRINT "The number is zero or positive" ' true branch PRINT "Positive numbers are > 0" ' true branch ELSE PRINT "The number is negative" ' false branch PRINT "Negative numbers are < 0" ' false branch END IF ' PRINT "Bye" ' this statement is always done END
The statements in the true branch are executed when
the question in the IF
statement is TRUE.
There can be as many statements as you want in the true branch.
The true branch consists of the statements
between the IF
statement
and the ELSE
statement.
Of course,
the statements in the false branch are executed when
the question in the IF
statement is FALSE.
There can be as many statements as you want in the false branch.
The false branch consists of the
statements between the ELSE
statement
and the END IF
statement.
In answer to the question, the user enters a 17. What will the new program print?