Previous Next

C for Loop

A for loop in C programming is a control structure for repetition that enables programmers to code a loop that will be repeated a certain number of times.

Syntax

for (initialization; testExpression; increment/decrement){
   // block of code
}

Example:

#include <stdio.h>

int main()
{
    int i;
    for (i = 0; i <= 6; i++)
    {
        printf("%d", i);
    }
    return 0;
}

Output:

0 1 2 3 4 5 6
Previous Next