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



write a program in c language that is able to compute the determinant of any 5*5 matrix from your..

Answer / 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

More Sciences AllOther Interview Questions

Which wave phenomenon is not common to both light and sound waves?

1 Answers  


Is 2 is a prime no?? Why?

1 Answers   HCL,


how many elements are common to living organisms?

0 Answers  


What is Green Petrol ?

0 Answers   UPPSC Uttar Pradesh Public Service Commission,


briefly explain how to use try and catch

0 Answers  






give me an example of a time where you needed more information to solve a problem . how did you go about gathering and analyzing information to solve the problem?

0 Answers   Royal Lancaster Hotel,


hiii sir i am sathish i have graduated my b. pharmacy as i am applying for masters in us the university which i was applied was doesn't required gre if a us visa counsellor was asked what is gre score what i have to tell the answer to get visa please provide me a suitable answer

0 Answers  


What is PEPSSI?

3 Answers  


tell me about a time that you had to deal with a conflict between a licensed and unlicensed personnel and how you handled the situation?

5 Answers   ADNH Abu Dhabi National Hotels, Drury Hotels, Holiday Inn, Hotel Landmark, Rixos Bab Al Bahr, Royal Lancaster Hotel, St Anthony Hotel, St Rose Hospital, Thompson Hotels,


what is the limit of total coli forms for cuttle fish?

0 Answers   Ford,


What is considered under the capital account of balance payment ?

1 Answers  


In geotechnical engineering, for wet mix macadam, what are the ranges of values of youngs modulus and poisson's ratio?

0 Answers  


Categories