C Program to Print Transpose of Matrix using Array

In this C Programming example, we will write a C Program to print Transpose of Matrix using Array.

What is the Transpose of a Matrix?

A Matrix is created by swapping/transposition of elements of rows into columns and columns into rows. It is known as Transpose of Matrix.

Here’s the visual representation of Transpose of a Matrix

Algorithm for Transpose of Matrix

Here’s the algorithm for Transpose of Matrix:

  1. START
  2. Read value of the array using Nested loop
  3. Interchange the value of row variable with column variable while printing
  4. Write the Transpose of a Matrix
  5. STOP

C Program to Print Transpose of Matrix using Array

Here’s the C Program to Print Transpose of Matrix using Array:

#include <stdio.h>
#include <conio.h>
int main()
{
    int matt[3][3],i,j;
 
    printf("Enter the elements of Matrix :\n");
    for(i=0; i<3; i++)
    {
        for(j=0; j<3; j++)
        {
            scanf("%d", &matt[i][j]);
        }
        printf("\n");
    }
    printf("Transpose of given matrix : \n");
    for(int a=0; a<3; a++)
    {
        for(int b=0; b<3; b++)
        {
            printf("%d\t", matt[b][a]);
        }
        printf("\n");
    }
    printf("Visit https://codewin.org for programming tutorials");
    getch();
}

Output

Here’s the output of the above C Program to print the transpose of a matrix using Array:

groot
groot

Leave a Reply

Your email address will not be published. Required fields are marked *