C++ do while loop print a message 10 times
#include <iostream> using namespace std; int main()/* ww w . j a v a2 s .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; }