title: creating a random number between 0 to 1 continuously
body: <p>I am trying to model a stock price movement in C++. I need to create a random number between 0 to 1.</p>
  
  <p>But it seems that the random number generator value keeps increasing and is not really random.</p>
  
  <p>The code looks like this:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;ctime&gt;
  #include&lt;cstdlib&gt;
  #include&lt;time.h&gt;
  
  using namespace std;
  
  int main()
  {
      double stockPrice = 25;
      int start = 0, end = 0;
      start = clock();
  
      srand (time(NULL));
      cout &lt;&lt; (double) rand() / (double) (RAND_MAX) &lt;&lt; endl;
      system("pause");
  
      while(stockPrice &gt; 18)
      {
          if(stockPrice == 20)
          {
              double probability = (rand()/(double)RAND_MAX);
              if(probability &lt;= (1/10))
              {
                  stockPrice = stockPrice-1;
              }
              else
              {
                  stockPrice = stockPrice +1;
              }
          }
          else if (stockPrice &lt; 20)
          {
              double probability = (rand()/(double)RAND_MAX);
              if(probability &lt;= (1/3))
              {
                  stockPrice = stockPrice -1;
              }
              else
              {
                  stockPrice = stockPrice +1;
              }
          }
          else 
          {
              double probability = (rand()/(double)RAND_MAX);
              if(probability &lt;= (2/3))
              {
                  stockPrice = stockPrice -1;
              }
              else
              {
                  stockPrice = stockPrice +1;
              }
          }
          cout &lt;&lt; stockPrice &lt;&lt; endl;
      }
  
      end = clock();
  
      double t = (double)(start-end)/CLOCKS_PER_SEC;
      cout &lt;&lt; t &lt;&lt; endl;
      system("pause");
  }
  </code></pre>
  
  <p>Not sure how to solve this.. Need some guidance...</p>