Matrix multiplication assistance

Here is my assignment:

Define a function that multiplies 2 matrices. The function should have 3 parameters for arrays. The first 2 parameters are the matrices to be multiplied. The third parameter should be the matrix which is the product. Print the result. Also define a function that transposes a matrix. The function should have 2 parameters for arrays. The first parameter is the matrix to be transposed and the second parameter is the transposed matrix. Print the result Matrix A is a 3x2 Matrix B is a 2x4

2 1
Matrix A= -1 0 Matrix B= 3 1 5 -1
3 1 4 -2 1 0

Here is what i have so far:

#include <stdio.h>

void mult_matrices(int a[][2], int b[][4], int result[][4]);
void print_matrix(int a[][3]);

int main(void)
{
int p[3][2] = { {2,1}, {-1,0}, {3,1} };
int q[2][4] = { {3,1,5,-1}, {4,-2,1,0} };
int r[3][4];

mult_matrices(p, q, r);
print_matrix(r);
}

void mult_matrices(int a[][2], int b[][4], int result[][4])
{
int i, j, k;
for(i=0; i<=2; i++)
{
for(j=0; j<=3; j++)
{
for(k=0; k<=2; k++)
{
result[i][j] += a[i][k] * b[k][j];
}
}
}
}

void print_matrix(int a[][4])
{
int i, j;
for (i=0; i<=2; i++)
{
for (j=0; j<=3; j++)
{
printf("%d\t", a[i][j]);
}
printf("\n");
}
}

any help will be greatly appreciated

Thanks,

Jenn
Topic archived. No new replies allowed.