EmbLogic's Blog

Write a program to Transpose the Matrix?

#include<stdio.h>
#include<stdlib.h>
int main()
{
int r,c,i,j,a[10][10],t[10][10];
printf(“Enter Max Size\n”);
scanf(“%d”,&r);
printf(“Enter Column\n”);
scanf(“%d”,&c);
printf(“Enter Element of Matrix1\n”);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“Elements are:\n”);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf(“%d\t”,a[i][j]);
}
printf(“\n”);
}
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
t[j][i]=a[i][j];
}
}
printf(“Transpose of Matrixs\n”);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf(“%d\t”,t[i][j]);
}
printf(“\n”);
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>