Skip to content
Justice Tech School

do while, break and continue

do while runs the body at least once. break leaves a loop and continue skips to the next round.

Example
int n = 0;
do { n++; } while (n < 3);
printf("%d\n", n);
for (int i = 1; i <= 6; i++) {
    if (i == 2) continue;
    if (i == 5) break;
    printf("%d ", i);
}
printf("\n");

Result

3
1 3 4 

Exercise

Skip one round.

if (x) ;

Quiz Test

Which loop runs at least once?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.