All pastes #370175 Raw Edit

Miscellany

public text v1 · immutable
#370175 ·published 2007-02-24 09:44 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define MIN_TRIALS 1
#define MAX_TRIALS 141

int main()
{
	int i;
	int s;
	int ran;

	s = 0;
	srand(time(NULL));
	
	printf("Flipping coin for %d trials. 0 is Heads, 1 is Tails. < is for items you need to record.\n");
	for(i = MIN_TRIALS; i < MAX_TRIALS; i++)
	{
		ran = rand();
		printf("Trial %d: %d", i, ran & 1);
		if(i < 11 || i % 5 == 0)
		{
			printf(" <\n");
		}
		else
		{
			printf("\n");
		}
		s = s + (ran & 1);
	}
	printf("Total tails: %d\n", s);
}