Program for Transpose of a given Matrix.
#include<stdio.h> #include<conio.h> main ( ) { int a[10][10],b[10][10],m,n,i,j; printf (“enter number of rows and co...
https://www.computersprofessor.com/2016/06/program-for-transpose-of-given-matrix.html?m=0
#include<stdio.h>
#include<conio.h>
main
( )
{
int
a[10][10],b[10][10],m,n,i,j;
printf
(“enter number of rows and columns”);
scanf
(“%d%d”, & m, &n);
printf
(“enter elements into the matrix”);
for
( i =0; i < m; i++)
for
(j = 0; j < n; j ++)
scanf(“%d,
& a[i][j]);
printf
(“transpose of a matrix is \n”);
for
(i=0; i < m; i++)
{
for
( j = 0; j < n; j++)
{
b[j][i]=a[i][j];
}
}
for
( i = 0; i < m; i ++)
{
for ( j =0; j < n; j ++)
{
printf (“%d \t “ b[i][j]);
}
printf (“\n”);
}
getch(
);
}
Out
Put:
Enter
number of rows & columns 3 3
Enter
elements into the matrix
1 2 3
4 5 6
7 8 9
Transpose
of a matrix is
1 4 7
2
5 8
3 5 9