There are two paths through this chart.
The "windshield wiper" decision is a two-way decision (sometimes called a "true-false" decision.) It seems small, but in programming very complicated decisions can be made up of many small decisions.
Here is a QBasic program that includes a two-way decision:
PRINT "Enter a Number" INPUT NUMBER ' IF NUMBER >= 0 THEN PRINT "The number is zero or positive" ' true branch ELSE PRINT "The number is negative" ' false branch END IF ' PRINT "Bye" ' this statement is always done END
The words IF
, THEN
,
ELSE
, and END IF
are brackets that divide
the part of the program into two branches.
The ELSE
is like a dividing line between the "true branch" and the
"false branch".
IF
statement always asks a question
(usually about the number in a variable).
END IF
.
A two-way decision is like picking which of two roads to take
to the same destination.
The fork in the road is the IF
statement, and the two roads come together
just after the END IF
statement.
The user runs the program and enters "12". What will the program print?