If the matrix A is singular, that is det(A) = 0, then we can not find the inverse of A.
But for every finite matrix A (square or rectangular) of real or complex elements, there is a unique generalized inverse, namely, Moore-Penrose invere X satisfying the four equations
AXA = A; XAX = X; (AX)* = AX; (XA)* = XA;
where * is means conjugate transpose. See
A. Ben-Israel, T.N.E. Greville, Generalized Inverses: Theory and Applications, Second Edition, Springer-Verlag, New York, 2003. pp.40-50.
There are another generalized inverse, for examples "group inverse of a square matrix" and "Drazin inverse of a square matrix."
As said Prof. Wiwat in the answers above. Just I add the Gauss-Jordan echelon form method for the non singular matrix, you perform it on the extended matrix ( A In ), you obtain ( In A-1 ). But still the inverse formula of a non singular matrix the most popular. If you don't interested in knowledge and want just results ( calculation) you can use some software of mathematics, the most popular and easy is Scientific work place, just write your matrix A -1 and click on the sign =? in the toolbar.
For a singular matrix, we can find inverse (pseudo inverse) using pinv() command in matlab. we can find inverse not only for singular matrices but for non-square matrices also using pseudo inverse concept.