The Boolean Expression is an expression that
evaluates to be either true or false.
If the Boolean Expression is true the code
associated with it will be executed. (STATEMENT A)
If the Boolean Expression is false, the code
associated with the else will be executed instead.
(A second IF-ELSE construct, with a second Boolean expression)
Example:
if (num == 0) if (BOOLEAN 1)
printf ("num equals 0\n"); STATEMENT A
else else
if (num < 0) if (BOOLEAN 2)
printf ("num is negative\n"); STATEMENT B
else else
printf ("num is positive\n"); STATEMENT C
In the example above, the first Boolean Expression is:
(num == 0)
If it is true, the code to execute (STATEMENT A) is:
printf ("num equals 0\n");
If it is false, the code to execute is:
if (num < 0)
printf ("num is negative\n");
else
printf ("num is positive\n");
What the above code represents logically is a three-way
decision, and to show this visually, the indentation is
often arranged as follows:
if (num == 0) if (BOOLEAN 1)
printf ("num equals 0\n"); STATEMENT A
else if (num < 0) else if (BOOLEAN 2)
printf ("num is negative\n"); STATEMENT B
else else
printf ("num is positive\n"); STATEMENT C