C Program for Finding Transpose of a Sparse Matrix

Here you will get C program to find transpose of a sparse matrix.
Transpose of a matrix is obtained by interchanging rows and columns. In another way, we can say that element in the i, j position gets put in the j, i position. Transpose  of the matrix B1 is obtained as B2 by inserting (i,j)th element of B1 as (j,i)th element in B2.



Enter the size of matrix (rows,columns):3 4

Enter no. of non-zero elements:4

Enter the next triple(row,column,value):1 0 5

Enter the next triple(row,column,value):1 2 3

Enter the next triple(row,column,value):2 1 1

Enter the next triple(row,column,value):2 3 2

After Transpose:

row column value
4 3 4
0 1 5
1 2 1
2 1 3
3 2 2

9 thoughts on “C Program for Finding Transpose of a Sparse Matrix

  1. Jayu

    It’s very simple and easy to understand code from all the sources available so far with me

  2. pallavi

    I want the algorithm for this code, it’s an assignment :(, can u pls post or reply me??

  3. Amit Gamot

    thanks a lot but code has a very small mistake ……..in last 2nd for loop
    its like :
    the corrected one:



Leave a Reply

Your email address will not be published. Required fields are marked *