codegurukool.com · Free coding tutorials & online compiler

Home › C Tutorial › C while loop

C while loop

Repeat while true.

do { } while runs at least once. Make sure the condition eventually becomes false.

Example code

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

Run this code in the online editor

← C switchC for loop →