Program to print a message 10 times. - C++ Statement

C++ examples for Statement:do while

Description

Program to print a message 10 times.

Demo Code

#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;
}

Result


Related Tutorials