2

C program to transpose of a matrix.

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a[5][5],b[5][5],m,n;
clrscr();
printf("Enter the number of rows and columns for matrice:(max 5)");
scanf("%d%d",&m,&n);
printf("Enter the elements of matrix");
for(i=0;i<m;i++)
 {
  for(j=0;j<n;j++)
   {
    scanf("%d",&a[i][j]);
   }
 }

 for(i=0;i<m;i++)
 {
  for(j=0;j<n;j++)
   {
    b[i][j]=a[j][i];
   }
 }
printf("\nNew matrix after transpose is: \n");


 for(i=0;i<m;i++)
  {
   for(j=0;j<n;j++)
    {
     printf(" %d",b[i][j]);
    }
   printf("\n");
  }
getch();
}

ks007

2 Comments

    • Well devlopersguide is not a company actually. It is just a small blog all you can do is just share our blogs.
      Thanks

Leave a Reply

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