I was trying to calculate the determinant of a 3 \* 3 matrix (or more) with the matrix values ranging from (-1, to 1). However, I get a result of 0 when I calculate the determinant.

[...]

```
srand(time(NULL));
    //Random generation of values between -1 and 1
    for(i = 0; i < 3; i++)
    {
        for(j = 0; j < 3; j++)
        {
            temp = (rand() % (500)) + 0;
            temp = temp/250;
            array[i][j] = (temp - 1);
        }

```

[...]

```
double array2[10][10];
double detrm = 0;
int s = 1;
int i, j, m, n, c;

for (c = 0; c < x; c++)
{
    m = 0;
    n = 0;
    for (i = 0; i < x; i++)
    {
        for (j = 0; j < x; j++)
        {
            array2[i][j] = 0;
            if (i != 0 && j != c)
            {
                array2[m][n] = a[i][j];
                if ( n < (x - 2))
                {
                    n++;
                }
                else
                {
                    n = 0;
                    m++;
                }
            }
        }
    }
    detrm = detrm + (s*a[0][c]*determinant(array2, (x - 1)));
    s = -1*s;
}
return(detrm);

```