for
Loopfor (init; condition; update) {
// code
}
Example:
for (int i = 0; i < 5; i++) {
cout << i << " ";
} /* Output in this case: 0 1 2 3 4 */
while
Loopwhile (condition) {
// code
}
do-while
Loopwhile
, but condition is checked after the loop.do {
// code
} while (condition);