C – Break and Continue

break: A branching statement that terminates the execution flow of a Loop or Switch case.

#include<stdio.h>
int main()
{
            int i;
            for(i=1 ; i<=10 ; i++)
            {
                        if(i==5)
                                    break;
                        printf(“i val : %d \n”, i);
            }
            return 0;
}

Break statement terminates the flow of infinite loop also:

#include<stdio.h>
int main()
{
            while(1)
            {
                        printf(“Infinite Loop \n”);
                        break;
            }
            return 0;
}

Continue: A branching statement that terminates the current iteration of loop execution.

#include<stdio.h>
int main()
{
            int i;
            for(i=1 ; i<=10 ; i++)
            {
                        if(i==5)
                                    continue;
                        printf(“i val : %d \n”, i);
            }
            return 0;
}
Scroll to Top