CHAPTER 12 / 26

C For Loop

Learn how to repeat a block using the for loop.

01 — Syntax

for (initialization; condition; update) {\n    // code\n}

02 — Example

#include <stdio.h>

int main() {
    for (int i = 1; i <= 5; i++) {
        printf("%d ", i);
    }

    return 0;
}

03 — Important Points

04 — Common Mistakes

05 — Real-World Use

For loops are common in array processing and counting tasks.

06 — Practice

Create a small program that demonstrates the main idea of C For Loop.

▶ Try It Yourself← PreviousNext →All Chapters