//Determinant of a
3*3 Matrix
#include<stdio.h>
#include<conio.h>
void
main()
{
int
i,j,a[3][3],d1,d2,d3,det;
clrscr();
//Enter the elements of Matrix
printf("Enter
the elements of matrix\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}
}
//Display of Matrix
printf("Matrix
is\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\t%d",a[i][j]);
}
printf("\n\n");
}
//Calculation of determinant of Matrix
d1=a[0][0]*((a[1][1]*a[2][2])-(a[1][2]*a[2][1]));
d2=a[0][1]*((a[1][0]*a[2][2])-(a[1][2]*a[2][0]));
d3=a[0][2]*((a[1][0]*a[2][1])-(a[1][1]*a[2][0]));
det=d1-d2+d3;
printf("Determinant
of 3*3 Matrix is = %d",det);
getch();
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.