continue Statement

It is sometimes desirable to skip some statements inside the loop. In such cases, continue statement is used. This is similar to break statement, but it will not jump out of the loop instead stop executing the set instructions inside loop body for current iteration and jumps to execute the body of loop for next iterations.

Syntax:
continue;

Example:
//Write a C Program Which use of continue statment.
//Write a C Program Which use of continue statment.
#include<stdio.h>
#include<conio.h>
void main(){
    int i, n=20;
    clrscr();
    for(i=1;i<=n;++i){
        if(i % 5 == 0) {
            printf("pass\n");
            continue;      /*this continue the execution of loop if i % 5 == 0 */
        }
        printf("%d\n",i);
    }
    getch();
}

break Statement
goto Statement

No comments:

Post a Comment