Nakagawa Yuuki - 9 months ago 73

C Question

So I **need to calculate the determinant matrix on 2x2 matrix**, **simple one**..

If you can, please write the code, because i don't understand like in the other thread, it's like i'm reading an English Literature + Code..

`#include<stdio.h>`

int main(){

int x[2][2]={{1,2},{3,4}};

int i,j,d;

for(i=0;i<=1;i++){

for(j=0;j<=1;j++){

printf(" %d ", x[i][j]);

}

printf(" \n");

}

return 0;

}

Thank You!

Answer Source

You don't need a loop to calculate the determinant of a 2x2 matrix, simply use:

```
int result = (x[0][0] * x[1][1]) - (x[0][1] * x[1][0]);
```