# includeint R,C; int i, j; int mat[10][10]; void display( int, int); void input( int, int); int Rank_Mat(int , int); void swap(int, int, int); void swap( int row1,int row2, int col) { for( i = 0; i < col; i++) { int temp = mat[row1][i]; mat[row1][i] = mat[row2][i]; mat[row2][i] = temp; } } int Rank_Mat(int row1, int col1) { int r, c; for(r = 0; r< col1; r++) { display(R,C); if( mat[r][r] ) // Diagonal element is not zero for(c = 0; c < row1; c++) if(c != r) { float ratio = mat[c][r]/ mat[r][r]; for( i = 0; i < col1; i++) mat[c][i] -= ratio * mat[r][i]; } else printf("\n"); else { for(c = r+1 ; c < row1; c++) if (mat[c][r]) { /* Find non zero elements in the same column */ swap(r,c,col1); break ; } if(c == row1) { -- col1; for(c = 0; c < row1; c ++) mat[c][r] = mat[c][col1]; } --r; } } return col1; } void display( int row, int col) { for(i = 0; i < row; i++) { for(j = 0; j < col; j++) { printf(" %d", mat[i][j]); } printf("\n"); } } void input( int row, int col) { int value; for(i = 0 ; i< row; i++) { for(j = 0 ; j
C Program to Find the Rank of a Matrix
Next Article to Read
Among many other career blogs, Fun-The-Mentals is a different blog to help students achieve their goals.. This blog is maintained by Debashish and group. The blog is intended to bring decent and genuine information to the students of colleges and universities to help their preparation for job in the competitive world.
Add on Facebook
?
0 comments:
Post a Comment