continue in C++
The C++ continue statement is used to execute other parts of the loop while skipping some parts declared inside the condition, rather than terminating the loop, it continues to execute the next iteration of the same loop. It is used with a decision-making statement which must be present inside the loop.
Syntax of continue
continue;
Flowchart of continue Statement
Example of continue Statement
Consider a scenario where all the numbers between 1 and 10 except number 5. So in this case, the idea is to use the continue statement after the value of i is 5. Below is the program for the same:
C++
// C++ program to demonstrate the // continue statement #include <iostream> using namespace std; // Driver code int main() { for ( int i = 1; i < 10; i++) { if (i == 5) continue ; cout << i << " " ; } return 0; } |
Output
1 2 3 4 6 7 8 9
Jump statements in C++
Jump statements are used to manipulate the flow of the program if some conditions are met. It is used to terminate or continue the loop inside a program or to stop the execution of a function.
Contact Us