/ Published in: C++
<p>This function returns a random number within a range.</p><p>For example:</p><p>// assigns low and high values for range</p><p><code>int rangeLow = 34, rangeHigh = 78;</code></p><p>// computes a random number between 34 and 78</p><p><code>myRandomNumber = computeRandomNumber(rangeLow, rangeHigh);</code></p>
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
int computeRandomNumber(int l, int h) { int randNumber; int range = h - l; randNumber = rand() % range + l + 1; return randNumber; }