Suppose i generate a whole bunch of random numbers and i want to get the percentage of how many times a single number is generated. Here's what i got so far...
Basically i'm generating a bunch of random coin tosses where 1 would be heads and 2 would be tails. How would i get a percentage of the number of times heads shows up in say 40 tries?Code:int randomcoinflip(int numberofcointosses) { int i; srand(time(NULL)); for (i = 0; i < numberofcointosses; i++) (rand()%2+1); return 0; }