123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Program to find Determinant of a Matrix.

--------------------------------------------------------------------------------



#include<stdio.h>
#include<conio.h>
#define LIMIT 10
void main()
{
int chckdgnl();
float deter();
float a[LIMIT][LIMIT],value;
int i,j,order;
clrscr();
printf("Enter order of determent :");
scanf("%d",&order);
for(i=0;i<order;i++)
{
for(j=0;j<order;j++)
{
printf("Enter (%d,%d) element of the determent :",i+1,j+1);
scanf("%f",&a[i][j]);
}
}

if(chckdgnl(a,order)==0)
value=0;
else
value=deter(a,order);
printf("Determinent Value :%f",value);
getch();
}

float deter(float a[][LIMIT],int forder)
{
int i,j,k;
float mult;
float deter=1;
for(i=0;i<forder;i++)
{
for(j=0;j<forder;j++)
{
mult=a[j][i]/a[i][i];
for(k=0;k<forder;k++)
{
if(i==j) break;
a[j][k]=a[j][k]-a[i][k]*mult;
}
}
}
for(i=0;i<forder;i++)
{
deter=deter*a[i][i];
}
return(deter);
}


int chckdgnl(float array[][LIMIT],int forder)
{
int i,j,k;
float nonzero;
for(i=0;i<forder;i++)
{
if(array[i][i]==0)
{
for(j=0;j<forder;j++)
{
if(array[i][j]!=0)
{
k=j;
break;
}
if(j==(forder)) //forder-1
return(0);
}
for(j=0;j<forder;j++)
{
array[j][i]=array[j][i]-array[j][k];
}
}
}
return(1);
}
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG