#include< iostream>
#include< ctime>

int coin()
{
   int flip;
   flip =  rand() % 2; // assign random numbers

   if (flip == 1) std::cout << "The flip was heads." << std::endl;
   else cout << "The flip was tails." << endl;

   return (flip);
}

void CoinFlip ()
{
   int NUM_FLIPS = 100;
   int heads = 0, tails = 0;
	
   // initialize the random number generator
   time_t rawtime;
   srand(rawtime); 
	
   // generate and count the number of heads and tails
   for (int count=1; count <= NUM_FLIPS; count++) {
      int face = coin();
      if (face == 1)  heads++;
      else  tails++;    
   }

   std::cout << "The number flips: " << NUM_FLIPS << std::endl;
   std::cout << "The number of heads: " << heads <<  std::endl;
   std::cout << "The number of tails: " << tails <<  std::endl;
}
