Advertisement
AedenCak3

C program to compute determinant of a 3X3 matrix

Dec 17th, 2021
942
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1.  
  2. #include<stdio.h>
  3. #include<string.h>
  4. int main()
  5. {
  6.     int arr[3][3];
  7.     int det,j,i;
  8.  
  9.     printf("enter elements of the array\n");
  10.     for(i=0;i<3;i++)
  11.     {
  12.         for(j=0;j<3;j++)
  13.             {
  14.                 printf("arr[%d][%d]",i,j);
  15.                 scanf("%d", &arr[i][j]);
  16.             }
  17.     }
  18.  
  19.  
  20.     det = arr[0][0]*(arr[1][1]*arr[2][2]-arr[1][2]*arr[2][1])-arr[0][1]*(arr[1][0]*arr[2][2]
  21.         -arr[2][0]*arr[1][2])+arr[0][2]*(arr[1][0]*arr[2][1]-arr[2][0]*arr[1][1]);
  22.  
  23.     printf("The Determinant of the matrix is: %d", det);
  24.  
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement