title: Strange behaviour of rand() in Xcode
body: <p>While using Apple Xcode, the C program I include below will always return a 5 for y but z will return a random number, even though they have the same expression. Can you identify a reason for this behaviour?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main()
  {
      int x,y,z;
      srand((unsigned int)time(NULL));
      x = ((unsigned int)time(NULL));
      y=((double)rand()/(double)(RAND_MAX)*10);
      z=((double)rand()/(double)(RAND_MAX)*10);
      printf("Time %d\n", x);
      printf("\n");
      printf("Number y %d\n", y);
      printf("\n");
      printf("Number z %d\n", z);
      printf("\n");
      return 0;
  }
  </code></pre>