Home | | Computer Science 11th std | C++ continue statement

Chapter: 11th Computer Science : Chapter 10 : Flow of Control

C++ continue statement

The continue statement works quite similar to the break statement.

continue statement

 

The continue statement works quite similar to the break statement. Instead of terminating the loop (break statement), continue statement forces the loop to continue or execute the next iteration. When the continue statement is executed in the loop, the code inside the loop following the continue statement will be skipped and next iteration of the loop will begin.

The following Figure describes the working flow of the continue statement


 

Illustraion 10.20 C++ program to display numbers from 1 to 10 except 6 using continue statement

#include <iostream>

using namespace std;

int main()

{

for (int i = 1; i<= 10; i++) {

if (i == 6)

continue;

else

cout<<i<< " ";

}

return 0;

}

Output

1 2 3 4 5 7 8 9 10

 

In the above example, the loop will iterate 10 times but, if i reaches 6, then the control is transferred to for loop, because of the continue statement.

 


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
11th Computer Science : Chapter 10 : Flow of Control : C++ continue statement |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.