This Is What I Have Come Up With.I think it is good enough what do you think??
(NOTE!!! This Will Run For 20 MINS)
#include <stdio.h>
#include <time.h>
/*** Function declaration ***/
void anotherMinute(void);
/**/
/*** Global variable ***/
int peopleInQueue;
/**/
/*** Arrivals and departures within a minute ***/
void anotherMinute(void) {
time_t t1,t2;
char thisrand;
t1 = time(NULL);
t2 = time(NULL);
while(t1) {
if(difftime(t2,t1)==1) {
if((rand() % 30)==0) {
thisrand = rand()%2;
if(thisrand)
peopleInQueue++;
else if (!thisrand && peopleInQueue)
peopleInQueue--;
}
}
if(difftime(t2,t1)==60) break;
t2 = time(NULL);
}
}
/**/
int main(void) {
int i;
int totalTime; /* Desired time in minutes */
peopleInQueue = 0; /* Define number of people initially in queue */
totalTime = 20;
for(i=0; i < totalTime; i++) {
anotherMinute();
printf("After %d minutes: %d people standing in queue\n", i+1, peopleInQueue);
}
return 0;
}