• Home
  • 2.19 continue Statement

2.19 continue Statement

View Categories

2.19 continue Statement

< 1 min read

Table of Contents

The continue statement skips the remaining statements in the current loop iteration and proceeds with the next iteration.

#include <stdio.h>

int main()
{
    int i;

    for (i = 1; i <= 5; i++)
    {
        if (i == 3)
        {
            continue;
        }

        printf("%d\n", i);
    }

    return 0;
}

Example Output #

1
2
4
5

Explanation #

When i becomes 3, the continue statement is executed:

if (i == 3)
{
    continue;
}

This skips the printf() statement for that iteration.

In a for loop, continue transfers control to the iteration expression (i++) before the next condition check. Therefore, i becomes 4 and the loop continues.

Unlike break, continue does not terminate the loop. It only skips the remainder of the current iteration.

Powered by BetterDocs

Leave a Reply

Your email address will not be published. Required fields are marked *