What is a control statment
-
Helps control the program
-
Sequence
-
Sequence structure
- statments execute one after another
-
Selection
-
Iteration
Selection Structure
-
IF Statement
-
used for single selection
- selects action if condition is TRUE
- skips if false
-
IF else statement
-
used for double selection
- selects action if true
- skips to next action if false
-
Switch statement
-
used for multiple selection
- selects on of many actions depending on condition
-
Break
- immediate exit from current statement
-
Continue
- skips the remaining statements in the loop body and goes with the next iteration
Iteration structure
-
Loops Statements
-
While and for loops
-
if action initially true:
- prefrom action zero or more times
-
If condition initially false
-
Do while:
-
While loop
- test continuation statement before executing loop body
-
Do while loop
- tests the loop continuation statement after executing the loops body
- do statment executes before checking the while condition, contiues until while is false