by Dinesh Thakur Category: C Programming (Pratical)

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



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.