1. ## Determinant Prob

where does the floating point error: divide by 0 occur

can anyone help me with this

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

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(0);
}

2. how do u put the code here with the formatting....when i post it....the indents go away

3. Use the [code][/code] forum bbcode tags.

4. Originally Posted by dantu1985
how do u put the code here with the formatting....when i post it....the indents go away

Use the code tags

It's symbolized by the # sign when you a posting.

5. My maths isn't that great...but aren't determinants for matrices integers and not floating point numbers?

6. hey pls help me on that floating point error...

i changed to int...still not working...

i have mult = a[j][i]/a[i][i]

so mult is float and so is a array

7. Closed - for multi posting the same thing without code tags.