C++ bool type as while statement controller

Description

C++ bool type as while statement controller

#include <iostream>

using namespace std;

int main()/*from ww  w  .j a  v a  2s  .co  m*/
{
    int i = 0;
    bool done = false;

    while (!done)
    {
        cout << i << endl;
        i++;
        if (i == 10)
            done = true;
    }

    cout << "All Finished!" << endl;
    return 0;
}



PreviousNext

Related