please can someone tell me how do i write a code for calculating determinant of a matrix in c.That works for all size of matrices eg. 3*3,4*4,7*7…and so on…

This may help you…

Check this one also…

Leibniz gives an O(N!) algorithm (or O(exp(number of nonzero entries of the matrix))), so it’s useless in programming.

The basic way of calculating the det. is to convert the matrix to upper triangular (having only zeroes below the main diagonal), when you’re only allowed to add/subtract multiples of some row to/from some other row - this operation doesn’t change the det., or swap some 2 rows - this multiplies the determinant by -1. And finding the det. of an upper triangular matrix is cakewalk - just multiply the numbers on its main diagonal.

The complexity of this is O(N^3), same as GEM.