Im busy trying to transpose my array but the code doesnt seem to be working...Can someone help me out please?
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define N 3
int find_inner_product (int *a,int *b,int size)
{int inner_product=0,i=0;
for (i=0;i<size;i++)
{inner_product=inner_product+ *(a+i)*(*(b+i));}
return inner_product;} /*function to do the inner product*/
int matrix_transpose(int a[][N],int size)
{int i=0,j=0,temp[N][N],transpose_matrix[N][N];
for ( i = 0; i<N; i++ )
{for( j = 0; j<N; j++ )
{ a[i][j]=temp[i][j];
temp[i][j]=transpose_matrix[j][i];
}
}
}
int main(void)
{
int matrix1[N][N],matrix2[N][N],i=0,j=0,inner_product=0,transpose_matrix[N][N];
printf("Please enter the values of the 3x3 Matrix: ");
for ( i = 0; i < N; i++ )
{for( j = 0; j< N; j++ )
{scanf("%d", &matrix1[i][j]);}
} /*this for loop goes through every number and stores it in the first matrix*/
printf("\nPlease enter the values of the second 3x3 Matrix: ");
for ( i = 0; i < N; i++ )
{for( j = 0; j< N; j++ )
{scanf("%d", &matrix2[i][j]);}
} /*this for loop goes through every number and stores it in the second matrix*/
inner_product=find_inner_product(matrix1,matrix2,N); /*calling the function to do the first row dot product*/
printf("\nThe inner product between the top two rows is %d",inner_product);
for ( i = 0; i < N; i++ )
{for( j = 0; j< N; j++ )
transpose_matrix[i][j]=matrix_transpose( matrix1[N][N],N);
}
for ( i = 0; i < N; i++ )
{for( j = 0; j< N; j++ )
printf("\n%d", transpose_matrix[i][j]);
}
}