title: Why do I always get the same sequence of random numbers with rand()?
body: <p>This is the first time I'm trying random numbers with C (I miss C#). Here is my code:</p>
  
  <pre><code>int i, j = 0;
  for(i = 0; i &lt;= 10; i++) {
      j = rand();
      printf("j = %d\n", j);
  }
  </code></pre>
  
  <p>with this code, I get the same sequence every time I run the code. But it generates different random sequences if I add <code>srand(/*somevalue/*)</code> before the <code>for</code> loop. Can anyone explain why?</p>