Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Loops execute a block of code repeatedly. Choosing the right loop type depends on whether you know the iteration count and when to check the condition.
for— Known iteration countfor (init; cond; update)while— Unknown count, check firstwhile (condition)do-while— Execute at least oncedo { } while (cond)range-for— Iterate over containersfor (auto x : arr)while (true) { ... } // or
for (;;) { ... }Use with break to create loops that terminate on a specific internal condition.