EQuestionAnswers.com Computer/Electronics Questions and Answers
C, C++, VC++, COM/DCOM, DLL and more
#Login #Sign up  Facebook Twitter TGoogle+
 

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++)
  {
10      for (j=0;j<10;j++)
11      {
12        m[i][j]=0;
13      }
14    }
15    printf("\n Enter size of row and colomn:");
16    scanf("%d %d",&r,&c);
17    printf("\n Enter the two matrices: \n");
18    for (i=0;i<r;i++)
19    {
20      for (j=0;j<c;j++)
21      {
22        printf("Enter element %d %d of m1: ",(i+1),(j+1));
23        scanf("%d",&m[i][j]);
24      }
25    }
26    printf("\n The matrix is: \n");
27    for (i=0;i<r;i++)
28    {
29      for (j=0;j<c;j++)
30      {
31        printf("%d ",m[i][j]);
32      }
33      printf("\n");
34    }
35    printf("\n The transpose of the matrix is: \n");
36    for (i=0;i<r;i++)
37    {
38      for (j=0;j<c;j++)
39      {
40        printf("%d ",m[j][i]);
41      }
42      printf("\n");
43    }
44    getch();
45  }
46 

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