Write a Program in C++ That Uses of Continue Statement Terminating an Iteration of a For Statement

// continue statement terminating an iteration of a for statement.
#include <iostream>
using namespace std;

int main()
{
   for ( unsigned int count = 1; count <= 10; ++count ) // loop 10 times
   { 
      if ( count == 5 ) // if count is 5,
         continue;      // skip remaining code in loop

      cout << count << " ";
   } // end for

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

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...