A for loop repeats work while a counter changes.

Loops

loops.c
#include <stdio.h>

int main(void) {
    int limit = ;
    int total = 0;

    for (int i = 1; i <= limit; i++) {
        total += i;
    }

    printf("total=%d\n", total);
    return 0;
}
#include <stdio.h>

int main(void) {
    int limit = ;
    int total = 0;

    for (int i = 1; i <= limit; i++) {
        total += i;
    }

    printf("total=%d\n", total);
    return 0;
}
#include <stdio.h>

int main(void) {
    int limit = ;
    int total = 0;

    for (int i = 1; i <= limit; i++) {
        total += i;
    }

    printf("total=%d\n", total);
    return 0;
}
for `for (init; condition; step)` groups the loop setup, test, and update.
accumulator An accumulator variable carries a running value across loop iterations.