Inverse Matrix 3×3
Here you will get and learn the program code to make inverse matrix of 3×3 in c programming.
Inverse Matrix formula 3×3
Inverse Matrix of 3×3 in C program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | //Inverse Matrix example #include<stdio.h> int main() { int a[3][3],i,j; float determinant=0; 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++){ for(j=0;j<3;j++) printf("%d ",a[i][j]); printf("\n"); } //Calculate the determinant for(i=0;i<3;i++) determinant = determinant + (a[0][i]*(a[1][(i+1)%3]*a[2][(i+2)%3] - a[1][(i+2)%3]*a[2][(i+1)%3])); printf("\nInverse of matrix is: \n"); for(i=0;i<3;i++){ for(j=0;j<3;j++) printf("%.2f\t",((a[(i+1)%3][(j+1)%3] * a[(i+2)%3][(j+2)%3]) - (a[(i+1)%3][(j+2)%3]*a[(i+2)%3][(j+1)%3]))/ determinant); printf("\n"); } return 0; } |
Output
Check out our other C programming Examples