// This program with "flip a coin" numerous times and report 
//  the number of heads and tails.

#include <iostream>
#include <cstdlib>
#include <time.h>

using namespace std;

int main()
{
 int i;
 int heads, tails, amount, result;
 int t1, t2, t3;
 
 // use the time() function in the library time.h to produce
 // a seemingly truely random number generator
 srand(time(NULL));

 // for ( initialize ; comparison ; increment )
 //     statement ;

 // Ask the user for the number of times to flip the coin
 cout << "Enter an integer to determine the number of coins flipped: ";
 cin >> amount;

 // set the values of haeds and tails to zero
 heads = 0;
 tails = 0;
 
 for ( i = 0 ; i < amount ; i++ )
    {
     // t1 = rand() % 2;
     result = rand();
     //cout << "Result: " << result << endl;
     t1 = result % 2;

     if (t1 == 0)
        {
         // cout << "T1: " << t1 << " is a head." << endl;
         heads++;
        }
     else
        {
         // cout << "T1: " << t1 << " is a tail." << endl;
         tails++;
        }
     //cout << "Loop counter: " << i << endl;
    }

 cout << "Number of heads: " << heads << endl;
 cout << "Number of tails: " << tails << endl;
}