Loop with both the continue and break statements. - C++ Statement

C++ examples for Statement:break

Description

Loop with both the continue and break statements.

Demo Code

#include <iostream> 
  
using namespace std; 
  
int main(int argc, const char * argv[]) 
{ 
        unsigned int array[10]; 
        unsigned int count = 0; 
      /*w ww.  j  a  va  2 s .c o  m*/
        do 
        { 
            if ((count % 2) == 0) 
            { 
                ++count; 
                continue; 
            } 
          
            array[count] = count; 
            cout << "Loop Iteration: " << array[count++] << endl; 
          
            if (count == 10) 
            { 
                break; 
            } 
        } while (true); 
      
        return 0; 
}

Result


Related Tutorials