Probability of happening function : <p>Basically I have a race, in every lap of the race each pilot have 5% probability of crashing.</p>

<p>How can I make a function that test the probability of crashing?</p>

<pre><code>
//the professor gave us this code but wasn't able to use it/ or understand it

//Returns the value 1 with probability prob. Otherwise, return 0

int probEvent(float prob){
    return prob &gt; ((float)rand()/RAND_MAX);
}


</code></pre>
