// july28ex1.cpp : Defines the entry point for the console application.
//Find random years

#include "stdafx.h"
#include "stdlib.h"
#include "time.h"
#define maxyear 20

int main(int argc, char* argv[])
{
	int years[maxyear];   /* range of array is [0] <->   [maxyear - 1]  */

    int whichyear, random_year, times;

	srand(time(NULL));


	/*zero out the entire array!  We really have2004 different int counters!  */

	for (whichyear=0; whichyear < maxyear; whichyear++) 
		years[whichyear] = 0;

    
	for (times=1; times<= 200; times++){
       
          random_year = rand() % maxyear;
		  years[ random_year ]++;

	} /* end for times */


	for (whichyear=0; whichyear < maxyear; whichyear++) 
	  if ( years[whichyear] > 0 )
		printf("Year %4d was chosen %d times\n", whichyear, years [whichyear]);



	return 0;
}