title: garbage value in C array
body: <p>I am trying to write a C code that will print a pyramid structure on screen, something like this.</p>
  <p><img src="https://i.stack.imgur.com/xF5W8.png" alt="enter image description here" /></p>
  <p>The corresponding code I've written is something like this.</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  #include &lt;stdlib.h&gt;
  
  void printArrayFunc(char arr[9][5]) {
    int i, j;
    printf(&quot;=========================================\nprinting the values\n&quot;);
    for (i = 0; i &lt; 5; i++) {
      for (j = 0; j &lt; 9; j++) {
        //printf(&quot;arr[%d][%d] = %d\n&quot;, i,j, arr[i][j]);
        if (arr[i][j] == 1)
          printf(&quot;*&quot;);
        else
          printf(&quot; &quot;);
      }
      printf(&quot;\n&quot;);
    }
  }
  
  
  int main() {
    int i, j;
    char arr[9][5] = {
      0
    };
  
    printf(&quot;============================\nfilling the values\n&quot;);
    for (i = 0; i &lt; 5; i++) {
      for (j = 4 - i; j &lt;= 4 + i; j++) {
        arr[i][j] = 1;
        // printf(&quot;arr[%d][%d]= %d\n&quot;,i,j,arr[i][j]);
      }
      //printf(&quot;\n&quot;);
    }
    printArrayFunc(arr);
  
    return 0;
  }
  </code></pre>
  <p>It is giving an output like</p>
  <p><img src="https://i.stack.imgur.com/WViAy.png" alt="enter image description here" /></p>
  <p>I know I'm doing some silly mistake but at this moment, I'm not able to find what is going wrong. Let me hear your comments on this.</p>