title: rand() generating same number upon compilation
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1117292/whats-the-right-way-to-use-the-rand-function-in-c">What&#39;s the Right Way to use the rand() Function in C++?</a>  </p>
  </blockquote>
  
  
  
  <p>I've been learning how to use the rand() function and I wrote a small guessing game in C++ as seen bellow, but the problem is, no matter how many times I compile the programs the generated number is the same -> 41</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;conio.h&gt;
  using namespace std;
  
  int main()
  {
      int x = rand()%100;
      int y=0;
      cout &lt;&lt; "Ghiceste numarul!" &lt;&lt; endl;
      cin &gt;&gt; y;
  
      while(y != x) {
  
           if(y &gt; x) {
              cout &lt;&lt; "Numarul tau este prea mare! Incearca un numar mai mic!" &lt;&lt; endl;
              cin &gt;&gt; y;
            }
  
               if(y &lt; x) {
                   cout &lt;&lt; "Numarul tau este prea mic!" &lt;&lt; endl;
                   cin &gt;&gt; y;
                 }
  
        if (y == x) {
        cout &lt;&lt; "FELICITARI, AI GHICIT NUMARUL!\n";
        return 0;
        }
      }
  }
  </code></pre>
  
  <p>I also tried to change the max value of rand() and it did change as long as I put it &lt; 41.</p>
  
  <p>Any ideas? I don't have a <em>clue</em> as to why this is happening. I am using CodeBlocks IDE and I tried rebuilding (CTRL+F11)</p>