Continue Statement in C Language –
Continue statement in C language with examples. Please read our previous article, where we discussed break statement in C language with examples. At the end of this article you will understand what is Continue Statement in C and when and how to use Continue Statement in C language with examples.
The CONTINUE statement provides a convenient way to immediately begin the next iteration of a FOR, WHILE, or REPEAT loop. While the BREAK statement exits a loop, the CONTINUE statement exits only the current loop iteration, immediately moving on to the next iteration. The CONTINUE statement is almost always used with an if…else statement. For a loop, the continue statement causes the conditional test and increment parts of the loop to execute. In the do-while-while loop, the continue statement causes program control to pass the conditional tests. given below the example to Understand Continue Statement in C Language
Read Also – Explain GoTo Statement in C ?
Flowchart of Continue Statement:
Syntax:
continue;
Example to Understand Continue Statement in C Language:
#include <stdio.h> int main() { for (int j=0; j<=8; j++) { if (j==4) { /* The continue statement is encountered when * the value of j is equal to 4. */ continue; } /* This print statement would not execute for the * loop iteration where j ==4 because in that case * this statement would be skipped. */ printf("%d ", j); } return 0; }
OutPut:
0 1 2 3 5 6 7 8
Value 4 is missing in the output, why? When the value of the variable j is 4, the program encounters a continue statement, which makes control to jump to the beginning of the loop for the next iteration, skipping the statements for the current iteration (this is why That is, printf is not executed when j) is equal to 4).
Hope you like this…
Tag –
Continue Statement in C Language
- AnchorSetup using Docker-Compose - October 18, 2024
- Devops assignment - October 17, 2024
- Deployment of vault HA using MySQL - September 18, 2024