title: Random Number Generator Within Given Range
body: <p>I'm trying to write a program that uses a function to generate 10 random numbers within a range provided by the user. It seems to work okay, other than the fact that the numbers returned are all 1's:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;ctime&gt;
  using namespace std;
  
  int rand_int(int min, int max);
  
  int main()
  {
      int min, max;
  
      cout &lt;&lt; "Hello user.\n\n"
           &lt;&lt; "This program will generate a list of 10 random numbers within a 
           given range.\n"
           &lt;&lt; "Please enter a number for the low end of the range: ";
      cin  &gt;&gt; min;
      cout &lt;&lt; "You entered " &lt;&lt; min &lt;&lt; ". \n"
           &lt;&lt; "Now please enter a number for the high end of the range: ";
      cin  &gt;&gt; max;
  
      while(min &gt; max){
          cout &lt;&lt; "Error: Your low number is higher than your high number.\n"
               &lt;&lt; "Please reenter your high number, or press ctrl + c 
                   to end program.\n";
          cin  &gt;&gt; max;
          cout &lt;&lt; endl;
      }
  
      for(int i = 0; i &lt; 10; i++){
          int rand_int(int min, int max);
          cout &lt;&lt; rand_int &lt;&lt; endl;
      }
  
      return 0;
  }
  
  
  int rand_int(int min, int max)
  {
      srand(time(0)); // Ensures rand will generate different numbers at different times
  
      int range = max - min;
  
      int num = rand() % (range + min);
  
      return num;
  }
  </code></pre>