title: Finding Determinant of a matrix in C
body: <p>This is the C code for determinant of matrix, But it gives compilation errors.</p>
  
  <p>Code is:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;math.h&gt;
  int m;
  
  float determinant(float b[][]);
  
  int main(void)
  {
  int i,j,m;
  printf("enter a no: ");
  scanf("%d",&amp;m);
  //printf("%d",m);
  float arr[m][m];
  for(i=0;i&lt;m;i++)
  {
      for(j=0;j&lt;m;j++)
      {
          scanf("%f",&amp;arr[i][j]);
          //printf("%f",arr[i][j]);
      }
  }
  
  
  for(i=0;i&lt;m;i++)
  {
      for(j=0;j&lt;m;j++)
      {
          printf("%f ",arr[i][j]);
      }
  
      printf("\n");
  }
  
  
  
  float det = determinant(arr);
  
  printf("Determinant= %f ", det);
  
  
  
  
  }
  
  float determinant(float b[][])
  {
  int i,j;
  int p;
  float sum = 0;
  float c[m][m];
  
  for(i=0;i&lt;m;i++)
  {
      for(j=0;j&lt;m;j++)
      {
          printf("%f ",b[i][j]);
      }
  
      printf("\n");
  }
  
  
  
  if(m==2)
  {
      printf("Determinant for m=2");
      sum = b[0][0]*b[1][1] - b[0][1]*b[1][0];
      return sum;
  }
  
  for(p=0;p&lt;m;p++)
  {
      int h = 0,k = 0;
      for(i=1;i&lt;m;i++)
      {
          for( j=0;j&lt;m;j++)
          {
              if(j==p)
                  continue;
              c[h][k] = b[i][j];
              k++;
              if(k == m-1)
              {   
                  h++;
                  k = 0;
              }
          }
      }
  
      m=m-1;
      sum = sum + b[0][p]*pow(-1,p) * determinant(c);
  
  }
  
  
  
  
  return sum;
  }
  </code></pre>
  
  <p>And the Compilation Errors are:</p>
  
  <pre><code>det.c:5:25: error: array type has incomplete element type
  det.c: In function ‘main’:
  det.c:36:2: error: type of formal parameter 1 is incomplete
  det.c: At top level:
  det.c:45:25: error: array type has incomplete element type
  det.c: In function ‘determinant’:
  det.c:91:3: error: type of formal parameter 1 is incomplete
  det.c:99: confused by earlier errors, bailing out
  Preprocessed source stored into /tmp/cc1Kp9KD.out file, please attach this to your bug report.
  </code></pre>
  
  <p>I think the error is in the passing of 2-D Array. when I passing it as a pointer then it gives warnings but no errors but it does not give the right result as in always gives determinant as Zero. So I guess the array is not being passed only and when I print it in the function determinant it doesn't print also.
  Please help as I am stuck because of this in my project.</p>