Loop Constructs

Learn how loops work and when to use them.

Control flow

Previously we learned about conditional statements. They manage the control flow of a program. The control flow is the execution order of the program’s commands.

The conditional statement chooses a branch of execution depending on the result of a boolean expression. However, this statement is not enough in some cases. We need extra features to manage the control flow. The loop construct helps us handle these cases.

The loop construct repeats the same block of commands multiple times. The single execution of this block is called a loop iteration. The loop checks its condition after each iteration. The check result defines if the next iteration should be executed.

Get hands-on with 1200+ tech skills courses.