Program No : 29 :

Write a program in C to read and display the transpose of 3x3 matrix ?

           program no  :29
 purpose : read and display the transpose of 3x3 matrix

#include <"conio.h">
#include<"stdio.h">

void main()

{

int mat[3][3],*p, trans[3][3], *t;

int i,j;

p=mat;
t=trans;
for(i=0; i<3;i++)
{
	for(j=0;j<3;j++)
		scanf("%d", p+i*3+j);

}

for(i=0; i<3;i++)
{
	for(j=0;j<3;j++)
		*(t+j*3+i)=*(p+i*3+j);

}

printf("transpose Matrix\n");

for(i=0; i<3;i++)
{
	for(j=0;j<3;j++)
		printf("%d  ", *(t+i*3+j));

	printf("\n");
}

getch();

}  
Back