This type of decision control structure includes a statement or block of statements on both paths.

If the Boolean expression evaluates to true, the statement or block of statements 1 is executed; otherwise, the statement or block of statements 2 is executed.

The general form of the statement is

PHP, Java, C++, C#

Notice: In PHP, Java, C++, and C#, the Boolean expression must be enclosed in parentheses.

Single statements can be written without being enclosed inside braces { }, and the if-else statement becomes

Visual Basic

Python

Leave a Reply

Your email address will not be published. Required fields are marked *

This article is taken from a book of mine. If you enjoyed it, please visit my author's page inand check out all of my books!