title: Uninitialized variable behaviour in C++
body: <p>I've checked myself, I wrote a program like this</p>
  
  <pre><code>int main() {
   int i;
   cout &lt;&lt; i;
   return 0;
  }
  </code></pre>
  
  <p>I ran the program a few times and the result was same all the time, zero.
  I've tried it in C and the result was the same.</p>
  
  <p>But my textbook says </p>
  
  <blockquote>
    <p>If you don’t initialize an variable that’s defined
    inside a function, the variable value remain undefined.That means the element takes on
    whatever value previously resided at that location in memory.</p>
  </blockquote>
  
  <p>How's this possible when the program always assign a free memory location to a variable? How could it be something other than zero(I assume that default free memory value is zero)?</p>