I want to find the determinant of a square matrix of size 3x3 for this I am using Gaussian elimination so that I can multiply diagonal elements and get the determinant. The code used is given. It is converting the matrix into upper triangular but not giving the solution pls give me a solution.
#include<stdio.h>
void determinant (float A[3][3]);
void main()
{
int i,j;
float A[3][3]={1,2,3,0,1,1,4,1,2};
determinant(A);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%ft",A[i][j]);
}
printf("n");
}
}
void determinant (float A[3][3])
{
int i,j,k;
for(k=0;k<2;k++)
{
for(i=k+1;i<3;i++)
{
for(j=0;j<3;j++)
{
A[i][j]=A[i][j]-(A[k][j]*(A[i][k]/A[k][k];
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire