C Program To Find Transpose Of Matrix Using Pointer

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

void main()
{

int arr[3][3],i,j,arr2[3][3],(*ptr)[3]=arr;
clrscr();
printf("Enter The Elements Of Array : ");
for(i=0;i<3;++i)
for(j=0;j<3;++j)
scanf("%d",&arr[i][j]);

printf("\nPrinting Matrix : \n");

for(i=0;i<3;++i)
{
for(j=0;j<3;++j)
printf("%d",arr[i][j]);

printf("\n");
}

for(i=0;i<3;++i)
{
for(j=0;j<3;++j)
{
arr2[j][i]=*(*(ptr+i)+j);

}

}

printf("\nPrinting Matrix Transpose : \n");

for(i=0;i<3;++i)
{
for(j=0;j<3;++j)
printf("%d",arr2[i][j]);
printf("\n");
}

getch();

}
Share on Google Plus

About Akash Manhas

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment