Let Us C (Chapter 8 : Arrays) : Program-11
(k) Write a program to obtain transpose of a 4 x 4 matrix. The transpose of a matrix is obtained
by exchanging the elements of each row with the elements of the corresponding column
// Let Us C (Chapter 8 : Arrays) : Program-11
/* Write a program to obtain transpose of a 4 x 4 matrix. The transpose of a matrix is obtained
by exchanging the elements of each row with the elements of the corresponding column. */
#include<stdio.h>
long int Arr[4][4];
unsigned int i,j;
void main()
{
clrscr();
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
printf("Enter Arr[%d][%d] element: ",i,j);
scanf("%ld",&Arr[i][j]);
}
}
printf("\nMatrix is :\n");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
printf("%0.2ld ",Arr[i][j]);
}
printf("\n");
}
printf("\nTranspose Matrix is: \n");
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
printf("%0.2ld ",Arr[j][i]);
}
printf("\n");
}
}
OUTPUT
Comments
Post a Comment