title: I want to initilize specific cells of a 2D array to 1. But my program keeps crashing
body: <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
      int arr[40] = {1,2,0,3,4,0,5,6,0,7,8,0,9,10,0,11,12,0,13,14,0,15,16,0,17,18,0,19,20,0,21,22,0,23,24,0,25,26,0,27};
      int i;
      int mat[27][27];
  
      //initilizing all cells of the matrix to zero
      for(int a=0 ; a&lt;27 ; a++)
      {
          for(int b=0 ; b&lt;27 ; b++)
          {
              mat[a][b]=0;
          }
      }
  
      //initilizing specific matix cells to 1
      for(int i=0 , j=1 ; j&lt;39 ; j++)
      {
        if((j+1)%3 == 0)
        {
          j=j+2;
          i=i+3;
          mat[i][j]=1;
          /*cout&lt;&lt;arr[i]&lt;&lt;" ";  //Print array element
          cout&lt;&lt;arr[j]&lt;&lt;" ";*/
          continue;
        }
        mat[i][j]=1;
        /*cout&lt;&lt;arr[i]&lt;&lt;" ";  //Print array element
        cout&lt;&lt;arr[j]&lt;&lt;" ";*/
      } 
  
      //displaying matrix
      for(int c=0 ; c&lt;27 ; c++)
      {
          for(int d=0 ; d&lt;27 ; d++)
          {
              cout&lt;&lt;mat[c][d]&lt;&lt;" ";
          }
          cout&lt;&lt;endl;
      }
  
  
  
      return 0;
  }
  </code></pre>