title: Why does rand() yield the same sequence of numbers on every run?
body: <p>Every time I run a program with <code>rand()</code> it gives me the same results.</p>
  
  <p>Example:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  int random (int low, int high) {
      if (low &gt; high)
          return high;
      return low + (rand() % (high - low + 1));
  }
  
  int main (int argc, char* argv []) {
      for (int i = 0; i &lt; 5; i++)
          cout &lt;&lt; random (2, 5) &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>3
  5
  4
  2
  3
  </code></pre>
  
  <p>Each time I run the program it outputs the same numbers every time. Is there a way around this?</p>