C++ examples for Statement:do while
Program to print a message 10 times.
#include <iostream> using namespace std; int main()// ww w .ja v a2s. c o m { int ctr = 0; // Holds the number of times printed. do { cout << "Computers are fun!\n"; ctr++; // Add one to the count, after each cout. } while (ctr < 10); // Print again if fewer than 10 times. return 0; }