i'm supposed to write a program that simulates cointoss. for each toss the program should print heads or tails and it would toss 100 times and counts the number off times each side of the coin appears. it should also call a seperate function 'flip' that takes no argument and returns 0 for tails and 1 for heads. pease help meeee its due today. this is what i have so far:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//#include <stdafx.h>
#include <iostream>
#include <cstdlib>
using std::cout;
using std::rand;
int flip();
int main(void)
{
int heads = 1;
int tails = 0;
int coinToss = 100;
int face;
for (int toss = 0; toss < coinToss; toss++)
{
flip();
if (toss == 1)
heads++;
else
tails++;
}
printf("%s%5s\n", "face", " heads or tails");
printf(" heads%5d\n", heads);
printf(" tails%5d\n", tails);
int flip()
{
return rand() % 2;
}
}