Loops
Repeat code multiple times without writing it again.
3 Types:
for loopwhile loopdo-while loopfor LoopBest when you know HOW MANY times to repeat.
Syntax:
for(initialization; condition; update) {
// code to repeat
}
Example: Print 1 to 5
for(int i = 1; i <= 5; i++) {
cout << i << endl;
}
Output:
1
2
3
4
5
for Loop Works