Write a program to find the transpose of the given matrix

Source Code

#include<stdio.h>
#include<conio.h>
int main (int argc, char *argv[])
{
  clrscr();
  int m[10][10];
  int i,j,r,c;
  for (i=0;i<10;i++)
  {
    for (j=0;j<10;j++)
    {
      m[i][j]=0;
    }
  }
  printf("\n Enter size of row and colomn:");
  scanf("%d %d",&r,&c);
  printf("\n Enter the two matrices: \n");
  for (i=0;i<r;i++)
  {
    for (j=0;j<c;j++)
    {
      printf("Enter element %d %d of m1: ",(i+1),(j+1));
      scanf("%d",&m[i][j]);
    }
  }
  printf("\n The matrix is: \n");
  for (i=0;i<r;i++)
  {
    for (j=0;j<c;j++)
    {
      printf("%d ",m[i][j]);
    }
    printf("\n");
  }
  printf("\n The transpose of the matrix is: \n");
  for (i=0;i<r;i++)
  {
    for (j=0;j<c;j++)
    {
      printf("%d ",m[j][i]);
    }
    printf("\n");
  }
  getch();
}

Find More from our code collection
Armstrong number, binary number to a decimal number, bubble sort, decimal number to binary number, factorial of the given number factors, fibonacci numbers, HCF and LCM, matrix, mergesort, salary of the employee. palindrome, quadratic equation, star patterns, series etc. and much more...
#Return to Example Source Code