title: how to use rand() function with a range in C
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1202687/in-c-how-do-i-get-a-specific-range-of-numbers-from-rand">In C, how do I get a specific range of numbers from rand()?</a><br>
    <a href="https://stackoverflow.com/questions/2999075/generate-a-random-number-within-range">Generate a random number within range?</a>  </p>
  </blockquote>
  
  
  
  <p>I'm stuck on how to use the rand() function and include a range for that random number. I need a random number between 67.00 and 99.99 only to be printed. </p>
  
  <p>This is what I have tried, but failed with...</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(void)
  
  {
      int x = rand();
  
      if(x&gt;=67.00)
      if(x&lt;=99.99)
            printf("%d\n",x);
          else
          printf("not in range");
  }   
  </code></pre>