#include <stdio.h> 
#include <stdlib.h> // srand,rand,RAND_MAX
#include <time.h>   // time

int main(void)
{
    int count, i;
    float number;
    int heads = 0, tails = 0;

    printf("Enter the number of coin tossing simulation: ");
    scanf("%d", &count);

    srand(time(NULL));

    for (i = 1; i <= count; i++) {

        number = (float) rand() / RAND_MAX;
        
        if (number < 0.5) {
            printf(" HEAD \n\n");
            heads++;

        } else {
            printf(" TAIL \n\n");
            tails++;
        }
    }

    printf("  Number of heads: %d   Pct: %.f \n", heads, 100.0 * heads / count);
    printf("  Number of tails: %d   Pct: %.f \n", tails, 100.0 * tails / count);

	system("pause");
	
    return 0;
}
