Write a program that calls a function in order to compute th

Write a program that calls a function in order to compute the determinant of array X. Read a matrix from “testmat.txt” and display the determinant to the user.
Finding the determinant involves expanding along a row or column and summing the weighted determinants of the sub-matrices obtained by omitting that particular row and column. For example, expanding along the top row and computing the determinants of the sub-matrices directly, we have that the determinant for X as defined below is
.
Your function must use loops to compute the determinant. All I/O is to be done in your main() function. Example output is
The determinant of matrix

| -7 -3 3|
| 6 2 -3|
| 11 -5 8|

is 80.
Test on the following matrices:

can you please give me the answer to this question in C

Solution

#include<stdio.h>
int main()
{
int b[3][3],row,col;
int det=0;
printf(\"enter elements: \");
for(row=0;row<3;row++)
      for(col=0;col<3;col++)
           scanf(\"%d\",&b[row][col]);
printf(\"\ the matrix is\ \");
for(row=0;row<3;row++){
      printf(\"\ \");
      for(col=0;col<3;col++)
           printf(\"%d\\t\",b[row][col]);
}

for(row=0;row<3;row++)
      det = det + (b[0][row]*(b[1][(row+1)%3]*b[2][(row+2)%3] - b[1][(row+2)%3]*b[2][(row+1)%3]));

printf(\"\ Determinant for the given matrix is: %d\",det);

   return 0;
}

Write a program that calls a function in order to compute the determinant of array X. Read a matrix from “testmat.txt” and display the determinant to the user.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site