Conditional Statements

Conditional statements execute if and only if a certain condition or conditions are true. They generally come in three forms: if statements, case statements, and logical AND/OR statements.

if Statements

if statements test numerical expressions. If the condition is true the statements inside the if block are executed. If the statement is false, one of two things can happen:

  • Nothing. The statements inside the if block are not executed, and the program continues as if they were not even there.

  • If an else statement is included inside the if block, these statements will be executed if the condition is false. In other words, this can be used to write “Do this if the condition is true, or do this if the condition is false, but ...

Get FreeBSD® Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.