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’s programming language.
#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();
}