A loop statement executes a group of statements repeatedly until a condition is met. There are 3 types of primitive loops in C++: for, while, and do…while.

Using functionality from [algorithm](<http://en.cppreference.com/w/cpp/algorithm>) header is preferable to hand-written loops.

If you want something an algorithm already does (or something very similar), the algorithm call is clearer, often more efficient and less error prone.

If you need a loop that does something fairly simple (but would require a confusing tangle of binders and adapters if you were using an algorithm), then just write the loop.

for loop

while loop

do-while loop

Loop Control statements: break and continue

Declaring variables in conditions

Range-Based For

Range-for over a sub-range