What is the difference between break and continue in C?

#include <stdio.h>

int main(void) {
    for (int i = 1; i <= 5; i++) {
        if (i == 2) continue;   // skip 2
        if (i == 4) break;      // stop at 4
        printf("%d ", i);
    }
    printf("\n");
    return 0;
}

Output:

Output of the above program is

1 3

continue skipped 2, and break ended the loop at 4. See break and continue.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.