0% found this document useful (0 votes)
10 views1 page

C Program for Matrix Transposition

This program transposes a matrix by taking input for the original matrix A, then creating a new matrix B where the rows and columns of A are swapped. It outputs the original matrix A and its transposed matrix B. The user inputs the number of rows and columns for matrix A, then the values. Matrix B is populated by taking each value from column i of A and placing it in row i of B.

Uploaded by

Ravi Choudhary
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

C Program for Matrix Transposition

This program transposes a matrix by taking input for the original matrix A, then creating a new matrix B where the rows and columns of A are swapped. It outputs the original matrix A and its transposed matrix B. The user inputs the number of rows and columns for matrix A, then the values. Matrix B is populated by taking each value from column i of A and placing it in row i of B.

Uploaded by

Ravi Choudhary
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

//Program to transpose a matrix: #include<iostream.h> #include<conio.

h> int main ( ) { clrscr( ) ; int a[20] [20], b[20] [20], I, j, m, n ; //Input rows and columns of matrix A[m] [n] . cout << \nInput matrix- A \n; for (I = 0 ; I < m ; ++i) { for (j = 0 ; j < n ; ++j) cin >> a[i] [j] ; } cout << \nMatrix-A : ; for(I = 0 ; I < m ; ++i0 { cout <<\n ;

for (j = 0 ; j < m ; ++j ) cout << << a[i] [j] ; } for (I =0 ; I < n ; ++i) { for(j = 0 ; j < m ; ++j) b[i][j] = a[j] [i]; } cout << \nTranpose of matrix is : \n ; for (I = 0 ; I < n ; ++I ) { for(j = 0 ; j < m ; ++j ) cout << \n ; } return 0 ; }

You might also like