If & Else If Statements

A quick and easy over view of the need to knows.

If Statements

  • the first line starts with if, followed by the condition you want to test for
  • th econdition statement goes between two round brackets
  • curly brackets are used to section off the different choices
  • the second choice goes after the word else and between its own curly brackets
  • if "IF" is false it will NOT continue checking subsequently nested if statements
  • typically comes in a giant list
  • always come is pairs followed by and else statement

Else-If Statements

  • use the usage of conditional statements that want our program to determine something from 2 or more things
  • symbols used such as "&" which makes bith things to be true in order to run, "||" which only one or the other has to be true to run, or "!" which reverses the condition that has to be falsed
  • runs faster
  • once one statement is deemed true it stops running

Examples

The whole point of if statements is used to implement a decision (using a test and a body).