CHAPTER 11 / 26

C While Loop

Learn how to repeat code while a condition remains true.

01 — Syntax

while (condition) {\n    // code\n}

02 — Example

#include <stdio.h>

int main() {
    int i = 1;

    while (i <= 5) {
        printf("%d ", i);
        i++;
    }

    return 0;
}

03 — Important Points

04 — Common Mistakes

05 — Real-World Use

Loops are essential for processing collections, repeated tasks and streams of data.

06 — Practice

Create a small program that demonstrates the main idea of C While Loop.

▶ Try It Yourself← PreviousNext →All Chapters