Question
This needs to written in c You are to write a program that contains a function that will compute the determinant of a matrix. Write
This needs to written in c
You are to write a program that contains a function that will compute the determinant of a matrix. Write your program such that it calls a function from main() that reads the matrix from a file, computes the determinant, and prints the resulting determinant from main(). You may write as many other functions as you desire; however, YOU MUST USE LOOPS. Include a function to explain the program to the user, and write this explanation to the screen. Assume type double for all variables. The determinant of a matrix is a measure of the size of the matrix. We express the determinant of a matrix as det(A).
Any matrix with a determinant of zero cannot have an inverse; and thus, we can evaluate the determinant to see if the inverse of a matrix exists or not. The determinant of matrix is found via the co-factor expansion. For example, assuming a matrix A with values
A = | a b | | c d |
the determinant of A is found as the co-factor cross product det(A) = ad - bc
For higher dimensional matrices, the determinant is found by expanding the matrix into its individual weighted co-factors and summing up the result in a certain fashion. This expansion must be performed across a single row or column of the matrix, but any row or column may be chosen. So, for a 3x3 matrix
A = | a11 a12 a13 | | a21 a22 a23 | | a31 a32 a33 |
the determinant of A is found as the co-factor cross product
a11 * (a22a33-a23a32) - a12 * (a21a33-a23a31) + a13 (a21a32-a22a31)
Your output should have the following form:
The determinant of matrix | -7 -3 3| | 6 2 -3| | 11 -5 8| is 80.
it has given me this to start off with and I need to use it:
#include
#include
#define ROWS 3
#define COLS 3
int determinant(int mat33[][3]);
int main(void)
{
FILE *fp;
char filename[20];
/*Declare additional Variables HERE*/
printf("Program to find determinant of 3x3 matrices ");
scanf("%s", filename);
if((fp=fopen(filename,"r")) == NULL)
{
printf("Matrix file %s does not exist ", filename);
exit(1);
}
/* Insert Code Here*/
}
int determinant(int mat33[][3])
{
/* Insert Code Here*/
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started