Programs That Can Loop

Learn how to execute a block of code multiple times.

We have found a way to break the strictly sequential flow of a program, by pushing one or however many statements within an if block. This means that our lines of code, other than those in if-else blocks, will get executed line by line, in sequence. But some lines of code will only get executed if a condition is True, otherwise, another set of lines will become a part of the execution. Sequential or selective, each line of code only gets executed once, and then our computer fetches the next one, and then the next.

The while loop

Wouldn’t it be great for the programmers if they could make the computer execute a block of code repeatedly while a condition is True?

Get hands-on with 1400+ tech skills courses.