98 943
Assignments Done
98.8%
Successfully Done
In May 2021

Question #23152
In the programming language of your choice write a function which determines if a 3x3 matrix is non-singular. Use remark statements to explain how the program works. You may want to use your calculator&rsquo;s programming language.
1
2013-01-30T08:09:43-0500
#include <conio.h>
#include <iomanip>
#include <iostream>

using namespace std;

int find_determinant(int (&matrix)[3][3])
{
int result = 0;
result += matrix[0][0] * matrix[1][1] * matrix[2][2];
result += matrix[0][1] * matrix[1][2] * matrix[2][0];
result += matrix[1][0] * matrix[2][1] * matrix[0][2];

result -= matrix[0][2] * matrix[1][1] * matrix[2][0];
result -= matrix[1][0] * matrix[0][1] * matrix[2][2];
result -= matrix[2][1] * matrix[1][2] * matrix[0][0];
return result;
}

void main()
{
/* Initialize a 3x3 matrix */
int matrix[3][3] = { {8, 0, 5},
{2, 4, 0},
{1, 7, 3} };

/* Display the matrix */
for (int x = 0; x < 3; x++)
{
for (int y = 0; y < 3; y++)
cout << setw(3) << matrix[x][y];
cout << endl;
}
cout << endl;

/* Check if it's determinant is equal to 0 */
if (find_determinant(matrix) == 0)
cout << "This matrix isn't invertible." << endl;
else
cout << "This matrix is non-singular." << endl;
_getch();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!