Continue Statement – C++

What it does:

continue causes the number 4 to be skiped in this case when printed out.

Code:


#include <iostream>

using namespace std;

int main()
{
    for(int count =1; count<=8; count++)
    {
        if(count==4)
        {
            continue; //skips the part code in the loop
        }//if
        
        cout << count << endl;
    }//for
    
    cout << "Used coninue to skip printing 4" << endl;
    
    return 0;
}//main

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s