Continue Statement

#include <iostream.h>

 int main()
 {
 for ( int x = 1; x <= 10; x++ ) {
 if ( x == 5 )
 continue;                 // skip remaining code in loop
  cout << x << " ";
 }
 cout << "\nUsed continue to skip printing the value 5";
 return 0;
 }

   OUTPUT:
              1 2 3 4 6 7 8 9 10
            used continue to skip printing the value 5

No comments:

Post a Comment