0 day streak
c / beginner
Snippet

The for Loop for Iteration

The for loop is used to repeat code a specific number of times. It combines initialization, a condition check, and an increment in one line.

snippet.c
c
1
2
3
for (int i = 0; i < 3; i++) {
// Repeat this block 3 times
}
Breakdown
1
int i = 0;
Initializes a counter variable named i to 0.
2
i < 3;
The loop continues as long as i is less than 3.
3
i++
Increases the counter i by one after each loop iteration.