-
Sequence logic, or sequential flow
-
Selection logic, or conditional flow
-
Iteration logic, or repetitive flow (today's focus)
-
For loop
-
While loop
-
There is raw data
-
Raw data should be processed - Functions
-
Processed data should be stored
-
Repeat sth large number of times (today's focus)
-
Remember results
-
Decide when to stop
- Loops are used when we want to execute same part of code multiple times or
- When you want to execute same part of code while some condition is true.
- When you know in advance how many iterations you will have
- Used when we do not know how many times some algorithm should be executed.
- We need to check condition every time, in order to know do we need to stop.