codegurukool.com · Free coding tutorials & online compiler

Home › C Tutorial › C for loop

C for loop

Count with a loop.

for (start; condition; step) keeps everything about the count in one line.

Example code

#include <stdio.h>
int main() {
  for (int i = 0; i < 5; i += 2) printf("%d ", i);
  printf("\n");
  return 0;
}

Run this code in the online editor

← C while loopC break and continue →