C Program to Find The Rank of a Matrix

C Program to Find The Rank of a Matrix: The maximum number of linearly independent vectors in a matrix is equal to the number of non-zero rows in its row echelon matrix.

C Program to Find The Rank of a Matrix

#include <stdio.h>
#define ORDER 2
int main() {
int i, j, n = ORDER, det, matrix[2][2];
printf("Enter your entries for the input matrix:\n");
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
scanf("%d", &matrix[i][j]);
}
}
det = (matrix[0][0] * matrix[1][1]) -
(matrix[0][1] * matrix[1][0]);
if (det) {
printf("Rank of the given matrix is 2!!\n");
} else {
printf("Rank of the given matrix is 1!!\n");
}
return 0;
}

Output Of Program

Enter your entries for the input matrix:
5
53
3
3
Rank of the given matrix is 2!!