C++ break statement exit for loop via if statement

Description

C++ break statement exit for loop via if statement

#include <iostream>

using namespace std;

int main()//from w w  w  .  j  a  va  2 s  .  c  o m
{
    int i;

    for (i=0; i<10; i++)
    {
        cout << i << " ";
        if (i == 5)
        {
            break;
        }
        cout << i * 2 << endl;
    }

    cout << "All Finished!" << endl;

    return 0;
}



PreviousNext

Related