2: // Demonstrates do while
3:
4: #include <iostream.h>
5:
6: int main()
7: {
8: int counter;
9: cout << "How many hellos? ";
10: cin >> counter;
11: do
12: {
13: cout << "Hello\n";
14: counter--;
15: } while (counter >0 );
16: cout << "Counter is: " << counter << endl;
17: return 0;
18: }
Output: How many hellos? 2
Hello
Hello
Counter is: 0