What is a Loop?

Basic Loops

What is a Loop?

🙋 Need help? Ask an expert now!

A loop is a control statement that repeatedly executes a block of statements until a condition is met. Depending on the loop, it can either execute a code block a fixed number of times or execute a code block while a given condition is true. Loops are commonly used in programming as it allows the reduces repetitive code and condenses it into 4 or 5 lines of code. Loops that never end are called infinite loops. You want to avoid infinite loops as they continue running until you quit your program, meaning it will kill your computer and overflow your memory.

Edit Me on GitHub!