C Program to Print Transpose of Matrix.

Transpose: The superscript “T” means “transpose“. Another way to look at the transpose is that the element at row r column c in the original is placed at row c column r of the transpose.

 

 

Let’s write the program which print transpose of given Matrix.

 

 

Step 1: Let’s open turbo C and write the following code in it.

 

 

Code:

 

 

//Add preprocessor

 

#include<stdio.h>

#include<conio.h>

void main()

{

int a[30][30],b[30][30],i,j;

 

 

//Clear Screen

clrscr();

printf(“enter all element of matrix : \n”);

for(i=0;i<3;i++)

{

for(j=0;j<3;j++)

{

scanf(“%d”,&a[i][j]);

}

}

printf(“transpose of matrix is : \n”);

for(i=0;i<3;i++)

{

for(j=0;j<3;j++)

{

b[i][j]=a[j][i];

 

//Print Result

printf(“%d\t”,b[i][j]);

}

printf(“\n”);

}

getch();

}

 

 

Step 2: Now save it and name it TRANSPOSE.CPP.

 

 

Step 3: Now compile it by pressing ALT+F9 or click on compile to check errors and correct them .

 

 

Step 4: Run the program by pressing ALT+R and see output.

 

 

Output:

 

transpose output

 

Enjoy  Coding

 

 

 

 

 

 

 

 

 

 

 

Tags: , ,