Determinant of a 3X3 matrix

 

Determinant of a 3X3 matrix


C Program
#include <stdio.h>
#include <stdlib.h>
int main()
{
   int Mat[3][3];
   int i,j,det;
   printf("Matrix 1:\n");
   for(i=0;i<3;i++)
   {
       for(j=0;j<3;j++)
       {
            printf("Enter element [%d][%d]: ", (i+1),(j+1));
            scanf("%d",&Mat[i][j]);
       }
   }
   det=Mat[0][0]*(Mat[1][1]*Mat[2][2] - Mat[1][2]*Mat[2][1]);
   det = det - (Mat[0][1]* (Mat[1][0]*Mat[2][2]- Mat[1][2]*Mat[2][0]));
   det= det + (Mat[0][2]*(Mat[1][0]* Mat[2][1] -Mat[1][1]* Mat[2][0]));
   printf("The determinant of the matrix is: %d",det);
}

0 Comments:

Post a Comment