Quick actions

cmd+k|ctrl+k

Navigation

Languages

Loops / Loop Control statements: break and continue / Essential C++

Snippet info

Language

Cpp

Visibility

public

Author

kkowalczyk

Created

2019-03-27T06:54:24Z

Updated

2019-03-27T06:54:24Z

#include <iostream>
using namespace std;

auto main() -> int
{
    for (int i = 0; i < 6; i++)
    {
        if (i % 2 == 0) // evaluates to true if i is even
            continue; // this will immediately go back to the start of the loop
        /* the next line will only be reached if the above "continue" statement 
           does not execute  */
        std::cout << i << " is an odd number\n";
    }
}
INFO