# 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.

Output

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

### 11 thoughts on “C Program for Finding Transpose of a Sparse Matrix”

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

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

for(i=0;i<=b1[0][1];i++)