title: Program with probability
body: <p>In the event where we need to generate probability, for example a bias coin with 75% of tossing head and 25% tossing tail. Conventionally, I will do it this way:</p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;ctime&gt;
  using namespace std;
  
  int main()
  {
      int heads=0, tails=0;
      srand(time(NULL));
      number = rand() % 100 + 1;  //Generate random number 1 to 100
            if (number &lt;= 75) //75% chance
                  heads++; //This is head
            else
                  tails++; //This is tail
  }
  </code></pre>
  
  <p>This is a working code, however when I answered a similar question on bias coin in SO for another user, some of the users mentioned about the multiple of 100. Since the random function generates uniform distribution, I feels that the above code is good enough for simulating a probability event.</p>
  
  <p>In this past SO posts, user Bathsheba mentioned somehting about multiples of 100: <a href="https://stackoverflow.com/questions/23015751/program-that-simulates-a-coin-toss-with-a-bias-coin/23015885#23015885">Program that simulates a coin toss with a bias coin</a> 
  I wanted to know what are the possible problems in my code in relation to that.</p>
  
  <p><strong>My question is:</strong> Is the above code an acceptable code to create a simulation with probability? Or are there any flaws in these codes which would affect the accuracy of the simulated results. If the above codes has flaws, what would be the correct way of implementing simulation for probability?</p>
  
  <p><strong>Edit:</strong> With a simulated test of 10,000,000 toss. It always generates at probability of approximately 75.01%-75.07% chance for tossing head. So what problems could there be when it is generating an seemingly accurate result. (<strong>The generated results didn't seemed to be skewed</strong>)</p>