Write a C program to determine determinant of a square matrix with the help of function int determinant(int a[][], n) where a is the matrix whose determinant is to be found and n is dimension of square matrix.

#include<stdio.h>
#include<math.h>
int determinant(int a[10][10], int n);
int main()
{
int i,j,a[10][10],n;
printf("enter the size of matrix:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("enter the elements of the matrix a[%d][%d]=",i,j);
scanf("%d",&a[i][j]);
}
}
determinant(a,n);
printf("the determinant of the matrix is %d", determinant(a,n));
}
int determinant(int a[10][10], int n)
{
int i,j,det;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
det=(a[0][0]*a[1][1]-(a[0][1]*a[1][0]));
}
return det;
}
}

Comments

Popular posts from this blog