- While Loop
- Counter Variables
- Sentinel Values
- Running Total
- Input Validation
- Do While Loop
- Menu Based Programs with loop and validation
- For Loop
- Nested Loops
- Variable Scope
- Infinite Loop
- Off By One
Increment and Decrement Op
++ and -- are operators that add and subtract 1 from their operands.
num = num + 1; num += 1; num++; // postfix ++num; // prefix num = num - 1; num -= 1; num--; // postfix --num; // prefix
A loop is a block of code that repeats:
- while loop: pre-test
- do while loop: post-test
- for loop: pre-test
while( expression ) { // body // of // loop }
do { // body // of // loop }while( expression );
for( init; expression; update ) { // body // of // loop }