---
title: 2.14 for Loop
description: "The `for` loop combines initialization, condition checking, and iteration in a single loop statement. It is commonly used when the number of iterations is controlled by a counter. ``` #include int main() { int i; for (i = 1; i"
url: "https://edcret.in/docs/c-programming/control-flow/2-14-for-loop/"
updated: "2026-09-06"
category: C Programming / Control Flow
---

# 2.14 for Loop

The `for` loop combines initialization, condition checking, and iteration in a single loop statement. It is commonly used when the number of iterations is controlled by a counter.

```
#include <stdio.h>

int main()
{
    int i;

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

    return 0;
}
```

### Example Output

```
1
2
3
4
5
```

### Explanation

The `for` loop contains three expressions:

```
for (i = 1; i <= 5; i++)
```

- `i = 1` initializes the loop counter.
- `i <= 5` is the condition checked before each iteration.
- `i++` increments the counter after each iteration.

The execution order is:

1. `i` is initialized to `1`.
2. The condition `i <= 5` is checked.
3. The loop body executes.
4. `i++` increments `i`.
5. Steps 2–4 repeat until the condition becomes false.

When `i` becomes `6`, the condition evaluates to `0`, so the loop terminates.
