Sometimes we want to only execute some code given some conditions. We can do this using a conditional statement. The most common form of this is the if/else statement:
This will only execute "statement" if the expression inside of the ()'s evaluates to "true". "statement" can be a compound statement (statements enclosed in {}'s, like:
Sometimes we want to two (or more) different code paths depending on the result of the initial expression. We can do this with an "else" part to the if:
This will execute statement1 if expr is true, or it will execute statement2 if expr is false. Either or both of statement1 or 2 can be compound statements:
example: