0% found this document useful (0 votes)
5 views3 pages

Calculate 3x3 Matrix Determinant

The document contains a C program that calculates the determinant of a 3x3 matrix input by the user. It prompts the user to enter 9 elements, displays the matrix, computes the determinant, and checks if the matrix is singular or non-singular based on the determinant value. The program includes examples of input and output for both a singular and a non-singular matrix.

Uploaded by

Sheela Mense
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Calculate 3x3 Matrix Determinant

The document contains a C program that calculates the determinant of a 3x3 matrix input by the user. It prompts the user to enter 9 elements, displays the matrix, computes the determinant, and checks if the matrix is singular or non-singular based on the determinant value. The program includes examples of input and output for both a singular and a non-singular matrix.

Uploaded by

Sheela Mense
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include<stdio.

h>

int main(){

int a[3][3], i, j;

long determinant;

printf("Enter the 9 elements of matrix: ");

for(i = 0 ;i < 3;i++)

for(j = 0;j < 3;j++)

scanf("%d", &a[i][j]);

printf("\nThe matrix is\n");

for(i = 0;i < 3; i++){

printf("\n");

for(j = 0;j < 3; j++)

printf("%d\t", a[i][j]);

determinant = a[0][0] * ((a[1][1]*a[2][2]) - (a[2][1]*a[1][2])) -a[0][1] * (a[1][0]

* a[2][2] - a[2][0] * a[1][2]) + a[0][2] * (a[1][0] * a[2][1] - a[2][0] * a[1][1]);

printf("\nDeterminant of 3X3 matrix: %ld", determinant);

if(determinant == 0)
printf("Singular Matrix");

else

printf("Non Singular Matrix");

return 0;

Enter the 9 elements of matrix:

0 0 0

12 3

4 5 6

The matrix is

0 0 0

1 2 3

4 5 6

Determinant of 3X3 matrix: 0

Singular Matrix

Enter the 9 elements of matrix:

123451234

The matrix is

1 2 3

4 5 1
2 3 4

Determinant of 3X3 matrix: -5

Non Singular Matrix

You might also like