adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Write a program in C to find the transpose of given matrix.

Write a program in C to find the transpose of given matrix.

#include<stdio.h>
#include<conio.h>
   void main()
    {
     int m[20][20],m1[20][20],i,j,r,c;
     clrscr();
     printf("Enter total no. of rows:-");
     scanf("%d",&r);
     printf("Enter total no. of calumns:-");
     scanf("%d",&c);
     printf("Enter a matrix of size %d * %d::-\n",r,c);
     for(i=0;i<r;i++)
       {
       for(j=0;j<c;j++)
        scanf("%d",&m[i][j]);
       }
      for(i=0;i<r;i++)
        {
        for(j=0;j<c;j++)
        m1[j][i]=m[i][j];
       } 
       printf("Transpose of matrix is as follows:-\n");
        for(i=0;i<r;i++)
          {
          for(j=0;j<c;j++)
           printf("%3d",m1[i][j]);
          printf("\n");
         }
     getch();
     }
     



Output:-

Related Programs:
  1. Write a program in C to find add the two given matrix.
  2. Write a program in C to find multiply the two given matrix.


Post a Comment

0 Comments