Pages

Wednesday, 17 June 2020

Continue in C language


What are the uses of Continue 


Continue statement is transfers execution control at the top of the loop where the condition checks. All statements after continue skips. The closing bracket of the loop does the same task. Continue statements should always be inside of a condition i.e. if, otherwise you may face infinite loop. Continue statement in C language I feel that the least useful feature.

Example : 

#include<stdio.h>

#include<conio.h>
/*##########################
     Girfa Student Help
     Example of continue
  ##########################*/

void main()
{
     int n;
     clrscr();
     n=0;
     while(n<=10)
     {
          n++;
          if(n<=5)
              continue;
          printf("\t%d",n);

     }
     getch();
}

Output :

6  7  8  9  10

when n is less than 6 continue to run and transfer the execution control to the beginning of the loop.



No comments:

Post a Comment