Answer to Question #214210 in C for ABHINEET GAUR

Question #214210

Mr. Umar while performing some operations comes to know that the image that he wants can be obtained by multiplying the original image with the pattern. Help Mr. Umar to get the resultant image by performing the matrix multiplication.

Note: Matric multiplication is possible only if the number of columns of the first matrix is the same as the number of rows of the second matrix.

Example:

Matrix A (M, N) and Matrix B(P,Q)

Then N and P should be the same to perform matrix multiplication otherwise its not possible

Matrix A(M,N) * Matrix B(P,Q)= Result(M,Q)

The resultant matrix will be in the order of M and Q


1
Expert's answer
2021-07-06T12:17:10-0400
int multiply_matrix(double* a[], int m, int n, double* b[], int p, int q, double* c[]) {
    if (n == p)
    {
        int i, j, k;
        for (i = 0; i < m; i++)
            for (j = 0; j < q; j++)
            {
                c[i][j] = 0;
                for (k = 0; k < n; k++)
                    c[i][j] += a[i][k] + b[k][j];
            }
        return 1;
    }
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS