C Break/Continue

Used to alter the normal flow of execution.
They are mainly used in loops
They are also used in if else, switch, functions, etc...


Break Statement

Used to exit the loop form executing further and moves to next statement after the loop.

Example
#include <stdio.h>

int main() {
    for (int i = 0; i < 10; i++) {
        if (i == 5) {
            break;  // Exit the loop when i equals 5
        }
        printf("%d ", i);
    }

    return 0;
}

Continue Statement

Used to skip the loop form executing further for this iteration and moves to next iteration.

Example
#include <stdio.h>

int main() {
    for (int i = 0; i < 10; i++) {
        if (i % 2 == 0) {
            continue;  // Skip even numbers
        }
        printf("%d ", i);
    }

    return 0;
}

Quick Recap - Topics Covered

C Break and Continue

Practice With Examples in Compilers

The Concepts and codes you leart practice in Compilers till you are confident of doing on your own. A Various methods of examples, concepts, codes availble in our websites. Don't know where to start Down some code examples are given for this page topic use the code and compiler.


Example 1
Example 1 Example 2 Example 3 Example 4 Example 5


Quiz


FEEDBACK