Enter 1 if you are hungry; 0 if you are not ? 0 Keep Shopping
The true branch is skipped because the question was answered with "false."
Here is the program again.
PRINT "Enter 1 if you are hungry; 0 if you are not" INPUT HUNGER ' IF HUNGER > 0 THEN PRINT "Buy Cookies" ' true branch END IF ' PRINT "Keep Shopping" ' this statement is always done END
The relational expression (the question) in the IF
statement tests if HUNGER
is greater than zero.
If the user enters "1" the expression is TRUE and the
"Buy Cookies" branch will execute.
But any number greater than zero will also work.
What will happen if the user enters a 10?