C Program For Transpose of Matrix

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10],b[10][10],r1,c1,i,j,t;
clrscr();
printf(" rows and col's of 1st matrix: ");
scanf("%d%d",&r1,&c1);
printf("enter  %d * %d = %d elements of 1st matrix: ",r1,c1,r1*c1);
for(i=0;i<r1;i++)
{
 for(j=0;j<c1;j++)
 {
 scanf("%d",&a[i][j]);
 }
}


for(i=0;i<r1;i++)
{
 for(j=0;j<c1;j++)
 {
 t=a[i][j];
 a[i][j]=a[j][i];
 a[j][i]=t;
 }
}
printf("After Transpose:\n" );

for(i=0;i<r1;i++)
{
 for(j=0;j<c1;j++)
 {
 printf("%4d",a[i][j]);
 }
 printf("\n");
}

getch();
}
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors and Social Networking. Feel Free to let me know any of your concerns about hacking or let me know if you need any more methods on hacking anything. Enjoy Learning

No comments:

Post a Comment