write a program in c language that is able to compute the
determinant of any 5*5 matrix from your program with at
least five examples and print the result

Answer Posted / vasanthi

#include<conio.h>
#include<stdio.h>

int a[20][20],m;
int determinant(int f[20][20],int a);
int main()
{
int i,j;
printf("----------------------------------------------------------------------\n");
printf("-------------------made by C code champ ------------------------------\n");
printf("----------------------------------------------------------------------\n");
printf("\n\nEnter order of matrix : ");
scanf("%d",&m);
printf("\nEnter the elements of matrix\n");
for(i=1;i<=m;i++)
{
for(j=1;j<=m;j++)
{
printf("a[%d][%d] = ",i,j);
scanf("%d",&a[i][j]);
}
}
printf("\n\n---------- Matrix A is --------------\n");
for(i=1;i<=m;i++)
{
printf("\n");
for(j=1;j<=m;j++)
{
printf("\t%d \t",a[i][j]);
}
}
printf("\n \n");
printf("\n Determinant of Matrix A is %d .",determinant(a,m));
getch();
}

int determinant(int f[20][20],int x)
{
int pr,c[20],d=0,b[20][20],j,p,q,t;
if(x==2)
{
d=0;
d=(f[1][1]*f[2][2])-(f[1][2]*f[2][1]);
return(d);
}
else
{
for(j=1;j<=x;j++)
{
int r=1,s=1;
for(p=1;p<=x;p++)
{
for(q=1;q<=x;q++)
{
if(p!=1&&q!=j)
{
b[r][s]=f[p][q];
s++;
if(s>x-1)
{
r++;
s=1;
}
}
}
}
for(t=1,pr=1;t<=(1+j);t++)
pr=(-1)*pr;
c[j]=pr*determinant(b,x-1);
}
for(j=1,d=0;j<=x;j++)
{
d=d+(f[1][j]*c[j]);
}
return(d);
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the difference between front loading thief and side vented theif? which one is best and why?

1724


How to create short keys in vb.net

1744


sap question.. i want to call a text module through the program which i have created with the help of so10 . how can i do this.

2099


How doe's the storm make in the sky.

1697


principle and calibration of uv. and why we use potassium dicromate solution for contol of absorbance

2397






How is concentration of surfactant is chosen for the dissolution media in dissolution development ?

1024


i am mathematics student. i have selected on sbi cerck on20 oct.ple any one before me has exp of PI ple help me waht they ask in PI.and what about mathematics ques ple contact on shahkr786@gmail.com

1729


HOW TO CUT A CAKE IN 8 PIECES IN 1 STROKE?

1796


What is the purpose of measuring inductance in motor windings?

1868


why we use special regent like hexane, taluene and potassium dicromate in uv clabration.

1806


what is multithreading

1544


generate a program to find the next date

1689


describe a time when you were responsible for organizing different types of personnel to get work done and some of them weren't very enthusiastic. what did you do?

5814


why do we get shocked by electric current?while earth has a 0 potential...

1484


what can be happen if terrorist attack on electric train by demage the high tension line..?

1724