TASK-
Write a C program to find the Transpose of a matrix.
Let A =
which has order 3x3 we need to find transpose of a which transforms the columns of a matrix into rows and rows into columns; The transpose of A would be :

CODE:
#include<stdio.h>
int main(){
int col,row;
printf("Enter number of rows and columns of A: ");
scanf("%d%d",&row,&col);
int mat[row][col],tran[col][row],i,j;
printf("\nEnter the entries of matrix");
for (int i=0;i<row;i++)
{
for (int j=0;j<col;j++)
{
printf("Enter entry [%d %d] : ",i+1,j+1);
scanf("%d",&mat[i][j]);
printf("\n");
}
}
for (int i=0;i<row;i++)
{
for (int j=0;j<col;j++)
{
tran[j][i]=mat[i][j];
}
}
printf("\n\n\tTranspose : \n");
for (int i=0;i<row;i++)
{
for (int j=0;j<col;j++)
{
printf("\t%d",tran[i][j]);
}
printf("\n");
}
getchar();
return 0;
}
Expected Output:
Its fabulous your blogs are helping me in my homework , thanks brother
ReplyDelete