title: Run time error - division by zero
body: <p>I have a run time issue when i debugged my script.</p>
  
  <p>It says :</p>
  
  <pre><code>Unhandled exception at 0x002a4f8e in test2.exe: 0xC0000094: Integer division by zero.
  </code></pre>
  
  <p>Although the line in question is a rand number generation.</p>
  
  <pre><code>if((rand() % miss) &lt; 3){ //line 40
    int phit = (rand()% hit);
  } else {
    bool pmiss = true;
  } 
  </code></pre>
  
  <p>Debugger stops at line 40 when it goes wrong (which i labelled above).</p>
  
  <p>My full script is here:
  <a href="http://www.paste.to/MzQ1ODM1" rel="nofollow">http://www.paste.to/MzQ1ODM1</a></p>
  
  <p>How should I have written the if statement if this causes such an error, i keep thinking like a PHP programmer which is v.frustrating to adapt!</p>