continue means skip the rest of the code in the body of the loop, go to the next test statement, and decide whether to continue looping. - C++ Statement

C++ examples for Statement:continue

Description

continue means skip the rest of the code in the body of the loop, go to the next test statement, and decide whether to continue looping.

Demo Code

#include <iostream> 
using namespace std ; 

int main(){/*from  ww  w.j a v a 2  s .com*/
    cout << " Enter positive numbers "; 
    cout << " Type CTRL +C to quit \n"; 
    int total = 0; 
    while (true ) { 
       int next ; 
       cin >> next ; 
       if (next <0) { 
          continue ; 
       } 
       total += next ; 
       cout << " Positive total is " << total << "\n"; 
    } 
}

Result


Related Tutorials