# C and C++ Program to Find Inverse of a Matrix

Here you will get C and C++ program to find inverse of a matrix.

We can obtain matrix inverse by following method.

• First calculate deteminant of matrix.
• Then calculate adjoint of given matrix. Adjoint can be obtained by taking transpose of cofactor matrix of given square matrix.
• Finally multiply 1/deteminant by adjoint to get inverse.

The formula to find inverse of matrix is given below. You can watch below video to learn how inverse is calculated.

In below program I have calculated the inverse of 3×3 matrix.

## C++ Program to Find Inverse of a Matrix

Output Category: Array A crazy computer and programming lover. He spend most of his time in programming, blogging and helping other programming geeks.

## 11 thoughts on “C and C++ Program to Find Inverse of a Matrix”

1. Someone once need help

thank you very much for your example, now i can go to bed easily =D . Really help my task to do inverse matrices from read files

2. megha kapse

why you use %3 finding determinant

1. Srikanth

Matrix size 3

3. aakash

Write a program in C++ to find the minor of every elements of a square matrix of any order.
The order of the square matrix should be entered by the user.

4. paulao

what is the function of the mode in the code

5. Levi Caesar

Thank u so much dude… u’ve helped us..

6. Madan

I did not understand this can you explain me clear ‘
cout<<((mat[(j+1)%3][(i+1)%3] * mat[(j+2)%3][(i+2)%3]) – (mat[(j+1)%3][(i+2)%3] * mat[(j+2)%3][(i+1)%3]))/ determinant<<"\t";

what is J+1, i+1 and so on?

7. Rashmi

Thank you very much to upload this program

8. Pavan kalyan

Bro i want the explanation about the full program if u have any related videos plz send to my mail

9. Arafat Hossen

What would be the changes to calculate 4*4 matrix or further ?

10. Md. Selim Reza

i don’t understand (j+1)%3 and (i+1)%3