by Dinesh Thakur

This is a C program where user asks to enter the value of matrix (order of matrix) and to find the transpose of matrix order. Means the rows will convert through columns what else the order of matrix. 

In the program variables are declared of Array type that will contain the value. User ask to enter value and the loop statement for verify the condition. The early loop statement will use to print a Matrix and the next one for finding the transpose of matrix. Nested loop statement is implemented in this program. And in the end to print the value on the screen.
Problem Statement:
This is C program to find the Transpose of matrix. User has to print a Matrix for transpose process.

  1. Declaring variable.
  2. Using loop statement.
  3. Printing result on the screen.

Here is source code of the C program to find the transpose of the matrix. The C program is successfully compiled. The program output is also shown below.

#include <stdio.h>

void main ( )
{
    int a[3][3],b[3][3],i,j,k;
    clrscr();
    printf("Enter Element for 3 x 3 Matrix\n");
    printf("Enter no. : ");
    for(i=0;i<3;i++)
        {
            for(j=0;j<3;j++)
                {    
                   scanf("%d",&a[i][j]);
                }
        }
           printf("\n");
           for(i=0;i<3;i++)
               {
                 for(j=0;j<3;j++)
                     {
                        printf("%d",a[i][j]);
                        printf(" ");
                     }
                        printf("\n");
               }
                        for(i=0;i<3;i++)
                            {
                                 for(j=0;j<3;j++)
                                    {
                                        b[i][j]=a[j][i];
                                    }
                             }
                                  printf("\nThe Transpose is :\n");
                                  printf("\n");
                                  for(i=0;i<3;i++)
                                      {
                                          for(j=0;j<3;j++)
                                               {
                                                   printf("%d",b[i][j]);
                                                   printf(" ");
                                               }
                                                   printf("\n");
                                      }
                                                   getch();
}

Transpose of a Matrix