title: rand() seeding with time() problem
body: <p>I'm having difficulty figuring out how to use rand() and seeding it with time() using Xcode. I want to generate random decimal numbers between 0 and 1.</p>
  
  <p>The code gives me seemingly random numbers for elements 1 and 2, but element 0 is always somewhere around 0.077. Any ideas why this would be?</p>
  
  <p>My code is:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  
  int main(void)
  {
  double array[3];
  
  double rand_max = RAND_MAX;
  
  srand((int)time(NULL));
  
  for (int iii = 0; iii &lt; 3; iii++)
      array[iii] = rand() / rand_max;
  
  for (int iii = 0; iii &lt; 3; iii++)
      printf("Element %d is: %lf.\n", iii, array[iii]);
  
  return(0);
  }
  </code></pre>
  
  <p>The output for several runs was as follows:</p>
  
  <pre><code>[Session started at 2010-09-11 21:19:07 -0500.]
  
  Element 0 is: 0.076918.
  
  Element 1 is: 0.753664.
  
  Element 2 is: 0.824467.
  
  The Debugger has exited with status 0.
  [Session started at 2010-09-11 21:19:12 -0500.]
  Element 0 is: 0.076957.
  Element 1 is: 0.411353.
  Element 2 is: 0.602494.
  
  The Debugger has exited with status 0.
  
  [Session started at 2010-09-11 21:19:16 -0500.]
  
  Element 0 is: 0.076988.
  
  Element 1 is: 0.937504.
  
  Element 2 is: 0.624915.
  
  The Debugger has exited with status 0.
  
  [Session started at 2010-09-11 21:19:24 -0500.]
  
  Element 0 is: 0.077051.
  
  Element 1 is: 0.989806.
  
  Element 2 is: 0.669757.
  </code></pre>