Lesson 10 of 50 · c
Loops – for
Duration: 7 mins
for is the most common loop for counting.
for (int i = 0; i < 10; ++i) {
printf("%d ", i);
}
The three parts are:
- initialization – executed once.
- condition – evaluated before each iteration.
- iteration expression – executed after each iteration.
You can omit any part if not needed (e.g., infinite loop).