C++ continue statement2 min read

The continue statement works like a break statement, instead of terminating the loop the continue statement skips the code in between and passes the execution to the next iteration in the loop.

In case of for loop, the continue statement causes the program to jump and pass the execution to the condition and update expression by skipping further statement. Whereas in the case of while and do…while loops, the continue statement passes the control to the conditional checking expression.

continue statement Flowchart:

Continue statement in java
continue statement

Syntax of continue statement in C++:


Example of C++ continue statement

Example: Use of continue in for loop in C++ programming.

Output:

As you can see in the above output the 6th iteration is skipped. When the value of i becomes 6, if statement is executed and hence the continue statement. Then the control is passed to the update expression of the for loop and i becomes 7.


Example: Use of continue in do-while loop loop in C++ programming

Output:

In the above output, 5th iteration is skipped.


MORE

Keith Number Program in C

In this tutorial, we will write a Keith number in C. It is one of the most asked questions in an interview. Before that, you …
Read More

Keith Number Program in C++

In this tutorial, we will write a Keith number in C++. It is one of the most asked questions in an interview. Before that, you …
Read More

Singly linked list Program C++

In this tutorial, we will write a C++ program to implement singly linked list. In this program, we will create a separate function for each …
Read More

Fascinating Number Program in C

In this tutorial, we will write a C program to check whether the given number is a Fascinating number or not. You may go through …
Read More

Peterson Number in C

In this tutorial, we will learn about the Peterson number and check if the number is Peterson or not in C. What is Peterson Number? …
Read More

Peterson Number in C++

In this tutorial, we will learn about the Peterson number and write a C++ program to check if the given number is a Peterson number …
Read More