title: Segmentation fault while trying to make 2x2 grid
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  
  void initialization(int n, int grid[n][n]){
    srand(time(0));
    for(int i = 0 ; i &lt; n; i++){
      int no1 = 0, no0 = 0;
      for(int j = 0; j &lt; n; j++){
        int checker = rand();
        if(no1 != n/2 &amp;&amp; no0 != n/2){
          if(checker % 2 == 0){
            grid[i][j]=1;
            no1++;
          }
          else{
            grid[i][j]=0;
            no0++;
          }
        }
        else if(no1 != n/2 &amp;&amp; no0 == n/2){
          grid[i][j]=1;
          no1++;
        }
        else if(no1 == n/2 &amp;&amp; no0 != n/2){
          grid[i][j]=0;
          no0++;
        }
      }
    }
    for(int i = 0; i &lt; n; i++){
      for(int j = 0; j &lt; n; j++){
        printf(&quot;%d&quot;, grid[i][j]);
      }
      printf(&quot;\n&quot;);
    }
  }
  
  int main() {
    int n;
    printf(&quot;Enter an even number between [2,80]: &quot;);
    scanf(&quot;%d&quot;,n);
    if(n % 2 == 1){
      return 1;
    }
    
    int grid[n][n];
    
    initialization(n, &amp;grid);
    return 0;
  }
  </code></pre>
  <p>So this is what im trying to do: Im trying to ask the user to enter an even value and then make an nxn grid. This nxn grid is supposed to have random number of n/2 1's and 0's in each row. But for some reason every time i run this code i get a segmentation error</p>