Use bool value to control while - C++ Statement

C++ examples for Statement:while

Description

Use bool value to control while

Demo Code

#include <iostream>

using namespace std;

int main()// ww w.j av  a2 s.c  o  m
{
    int i = 0;
    bool done = false;

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

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

Result


Related Tutorials