Hey!!! help!! help!! help!! Very very very urgent!! i needed a source code for C
ID: 3638566 • Letter: H
Question
Hey!!! help!! help!! help!!Very very very urgent!!
i needed a source code for C++ to find the determinant of a 8x8 matrix.
The matrix looks like this:
A:(
0.6791 0.0987 0.4942 0.0305 0.8055 0.9787 0.5216 0.973
0.3955 0.2619 0.7791 0.7441 0.5767 0.7127 0.0967 0.649
0.3674 0.3354 0.715 0.5 0.1829 0.5005 0.8181 0.8003
0.988 0.6797 0.9037 0.4799 0.2399 0.4711 0.8175 0.4538
0.0377 0.1366 0.8909 0.9047 0.8865 0.0596 0.7224 0.4324
0.8852 0.7212 0.3342 0.6099 0.0287 0.682 0.1499 0.8253
0.9133 0.1068 0.6987 0.6177 0.4899 0.0424 0.6596 0.0835
0.7962 0.6538 0.1978 0.8594 0.1679 0.0714 0.5186 0.1332);
please help me...
thanks in advance
Explanation / Answer
please rate - thanks
#include<iostream>
#include<cmath>
using namespace std;
double determ(double[][10],int);
void input(double[][10],int);
void print(double[][10],int);
int main()
{
double a[10][10];
int n;
int result;
cout<<"Enter dimension of matrix: ";
cin>>n;
input(a,n);
print(a,n);
cout<<"The determinant is:"<<determ(a,n)<<endl;
system("pause");
}
void input(double b[][10],int m) //FUNCTION FOR READING MATRIX
{int i,j;
for( i=0;i<m;i++)
for(j=0;j<m;j++)
{cout<<"Enter value at row "<<i<<" column "<<j<<": ";
cin>>b[i][j];
}
}
void print(double b[][10],int m)
{int i,j;
cout<<" Matrix ";
for( i=0;i<m;i++)
{for(int j=0;j<m;j++)
cout<<b[i][j]<<" ";
cout<<endl;
}
}
double determ(double a[][10],int m)
{ int i,j,k;
double mult,d=1;
for(i=0;i<m;i++)
{ for(j=0;j<m;j++)
{mult=a[j][i]/a[i][i];
for(k=0;k<m;k++)
{if(i==j) break;
a[j][k]=a[j][k]-a[i][k]*mult;
}
}
}
for(i=0;i<m;i++)
d=d*a[i][i];
return d;
}