Continue statement terminating an iteration of a for statement. - C++ Statement

C++ examples for Statement:continue

Description

Continue statement terminating an iteration of a for statement.

Demo Code

#include <iostream> 
using namespace std; 

 int main() /*from w  w  w .j a  v  a  2 s.  c  o m*/
 { 
     for ( int count = 1; count <= 10; ++count ) // loop 10 times 
     { 
         if ( count == 5 ) // if count is 5, 
            continue;           // skip remaining code in loop 

        cout << count << " "; 
     }

    cout << "\nUsed continue to skip printing 5" << endl; 
 }

Result


Related Tutorials