I have written a code for finding a transpose of a matrix as a separate program, it worked well.
But when Iam using that function into my main program, Iam getting wrong ans....
This was my code for function......
float trpse(int r,int c,float a[r][c],float atr[c][r])
{ int i,j;
for(i=0;i<c;i++)
{
for(j=0;j<r;j++)
{
atr[i][j]=a[j][i];
}
}
}
I am using like this.....
float trpse(int,int,float[20][20],float[20][20]);
float A[20][20],At[20][20],yb[20][20],Ayb[20][20];
printf("for A:\n");
for(i=0;i<ar;i++)
{
for(j=0;j<ac;j++)
{
scanf("%f",&A[i][j]);
}
}
trpse(ar,ac,A,At);
for(i=0;i<ac;i++)
{
for(j=0;j<ar;j++)
{
printf("%f ",At[i][j]);
}
printf("\n");
}
For example:
My input is.....
for A:
1 2 3
4 5 6
and
Iam expecting to get this out of the function trpse:
1 4
2 5
3 6
But I am getting this.
1.000000 0.000000
0.000000 0.000000
0.000000 0.000000