The break statement is used to terminate the innermost loop. It generally terminates a loop or a break statement. The continue statement skips to the next iteration of the loop. Below is the C program to demonstrate break and continue in C:
#include <stdio.h>
int main()
{
for (int i = 1; i <= 10; i++)
{
if (i == 2)
{
continue;
}
if (i == 6)
{
break;
}
printf(“%d “, i);
}
return 0;
}
Output
1 3 4 5