title: Why does rand()%20+10 keep returning teens in c++?
body: <p>Whenever I try to run this code it returns numbers between 10 and 19 too but I intend return in the range between 20 and 30. I thought the pattern would be: %min+range but it seems useless although %50+50 turns back numbers between 50 and 99 but any other minimum does not work. Why?</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;cstdlib&gt;
  #include&lt;ctime&gt;
  
  using namespace std;
  int main()
  {
      srand(time(0));
      for(int i=1; i&lt;100; i++)
      {
          cout&lt;&lt;rand()%20+10&lt;&lt;endl;
      }
      return 0;
  }
  </code></pre>