// 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, j;
 int heads, tails, amount, result;
 int t1, t2, t3;
 bool keepGoing;

 keepGoing = true;
 
 // 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 numbers generated: ";
 cin >> amount;

 for ( i = 0 ; i < amount ; i = i + 5 )
    {

     for ( j = 0 ; j < 5 ; j++ )
         {
          result = rand();
          cout << result << "  ";

          if (i+j+1 >= amount)
              break;
         }

     cout << endl;

    }

 cout << endl << endl;

 for ( i = 0 ; i < amount ; i = i + 5 )
    {

     for ( j = 0 ; j < 5 && keepGoing == true ; j++ )
         {
          result = rand();
          cout << result << "  ";

          if (i+j+1 >= amount)
              keepGoing = false;
         }

     cout << endl;

    }

}