C++20 sections · 1024 units
Open in Course

What is a Loop?

The concept of iteration

A loop runs the same code multiple times. You write the instructions once, and the loop executes them repeatedly based on a condition you specify. Without loops, printing numbers 1 to 100 means writing 100 separate cout statements.

With a loop, you write one cout inside a loop body and let the loop handle repetition. Every loop needs a condition that decides when to stop. When the condition becomes false, the loop exits and your program continues with whatever comes next.