Question: C PROGRAM need same output 1 - WAP to find the product of given matrix. Description: Read no.of rows and columns for 2 arrays from

C PROGRAM need same output

1 - WAP to find the product of given matrix.

Description:

Read no.of rows and columns for 2 arrays from user and allocate the memory dynamically using malloc or calloc (Assume Matrix A and Matrix B).

Read the Matrix A and B from user.

Find the product for matrix A with matrix B amd store the result in Matrix R.

Let say Name of the matrix is A and no. Of rows = columns = 3.

Matrix A

1 2 3
1
2
3
1
2
3

Matrix B

1 1 1
2
2
2
3
3
3

Final Result :

Result = A * B

1 2 3 1 1 1

R= 1 2 3 x 2 2 2

1 2 3 3 3 3

R1 = [(1 * 1) + (2 * 2) + (3 * 3) (1 * 1) + (2 * 2) + (3 * 3) (1 * 1) + (2* 2) + (3 * 3)]

Result matrix is

14 14 14
14 14 14
14 14 14

Pr-requisites:

2D Arrays / Pointers.

DMA.

Objective:

To understand the concept of

DMA

Double Pointers / 2D array.

Inputs:

No.of rows, Columns and row * column values for the matrix A and matrix B.

Sample output: Test case1: Enter number of rows : 3 Enter number of columns : 3 Enter values for 3 x 3 matrix : 1 2 3 1 2 3 1 2 3 Enter number of rows : 3 Enter number of columns : 3 Enter values for 3 x 3 matrix : 1 1 1 2 2 2 3 3 3 Product of two matrix : 14 14 14 14 14 14 14 14 14

Test case 2: Enter number of rows : 3 Enter number of columns : 3 Enter values for 3 x 3 matrix : 1 2 3 1 2 3 1 2 3 Enter number of rows : 2 Enter number of columns : 3 Matrix multiplication is not possible

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!