title: Why does array prints garbage values?
body: <p>I have created a 2d array and initialized to 0 in C++.</p>
  <pre><code>int n;
  cin&gt;&gt;n;
  int ar[n][n]={0};
  
  for(int i=0;i&lt;n;i++)
  {
      for(int j=0;j&lt;n;j++)
      {
          cout&lt;&lt;ar[i][j]&lt;&lt;&quot; &quot;;
      }
      cout&lt;&lt;endl;
  }
  </code></pre>
  <p>When I print this array, it prints random garbage values in the first row as shown below</p>
  <pre><code>0 0 4294220 0 0 0
  0 0 0 0 0 0
  0 0 0 0 0 0
  0 0 0 0 0 0
  0 0 0 0 0 0
  0 0 0 0 0 0
  
  </code></pre>
  <p>Why is this happening. I have read about variable length arrays <a href="https://stackoverflow.com/questions/1887097/why-arent-variable-length-arrays-part-of-the-c-standard">here</a>. But I can't find any explanation why is this happening.</p>