Looping Structures - For Loop
What are loops?
- Loops runs the same block of code over and over again
- For loop is a count controlled loop where the program knows in advance how many times the loop is to be executed.
For Loop
- The ideal loop to use when you know the exact number of times you want to run a block of code.
- Examples:
- Play a game 3 times
- Ask for a list of 5 numbers
- Flip a coin 100 times
- Display a message 4 times
- Choose 6 different numbers between 1 and 49