Friday , 29 March 2024
Home » Tutorials » C programming » C program to Find the Transpose of a given matrix

C program to Find the Transpose of a given matrix

Program :

#include 

int main()
{
 int a[4][4],i,j,b;

 for(i=0;i<4;i++)
 {
   printf("\nEnter elements of %d row of Matrix: ",i+1);
   for(j=0;j<4;j++)
   scanf("%d",&a[i][j]);
 }

 for(i=0;i<4;i++)
 {
  for(j=i+1;j<4;j++)
  {
   b=a[i][j];
   a[i][j]=a[j][i];
   a[j][i]=b;
  }
 }

 printf("\n Transposed Matrix:\n\n");
 for(i=0;i<4;i++)
 {
  for(j=0;j<4;j++)
   printf("%4d",a[i][j]);
  printf("\n");
 }
 return 0;
}

About Rajeel

I'm Rajeel, a teen blogger from India who loves computers, sports, internet and all other kind of tech stuffs. This blog thing is one of my favourite hobby and the one that eats up much of my time. But Really, I'm loving it :) Find me in G+

Leave a Reply

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

*

Scroll To Top