c / beginner
Snippet
Simple For Loop
A for loop repeats a block of code a specific number of times, using a counter variable to track progress.
snippet.c
1
2
3
for (int i = 0; i < 5; i++) {printf("Iteration: %d\n", i);}
Breakdown
1
int i = 0;
Initializes the counter variable to zero.
2
i < 5;
The loop continues as long as this condition is true.
3
i++
Increments the counter by 1 after each iteration.