WAP in C to Find Transpose of a Matrix?

#include<stdio.h>
#include<conio.h>
int main()
{
int m, n, c, d, p[10][10], t[10][10];
clrscr();
printf(“Enter the number of rows and columns of matrix\n”);
scanf(“%d%d”, &m, &n);
printf(“Enter the elements of matrix\n”);
for (c = 0; c < m; c++)
for(d = 0; d < n; d++)
scanf(“%d”,&p[c][d]);
for (c = 0; c < m; c++)
for( d = 0 ; d < n ; d++ )
t[d][c] = p[c][d];
printf(“Transpose of entered matrix :-\n”);
for (c = 0; c < n; c++) {
for (d = 0; d < m; d++)
printf(“%d\t”,t[c][d]);
printf(“\n”);
}
getch();
return(0);
}

Output :-

transmat

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s