#### Question Details

[answered] MIT 6.S096 Assignment 1, Problem 2 Problem 2: Matrix Multip

Given an RA ?CA matrix A and an RB ?CB matrix B, with 1 ? RA, RB ,CA,CB ? 300, write a programthat computes the matrix product C = AB. All entries in matrices A and B are integers with absolutevalue less than 1000, so you don?t need to worry about overflow. If matrices A and B do not have theright dimensions to be multiplied, the product matrix C should have its number of rows and columnsboth set to zero.Use the code at provided in the file matrix.data.zip as a basis for your program?the input/outputneeded is already written for you. Matrices will be stored as a structure which we?ll typedefas Matrix. This structure will contain the size of our matrix along with a statically-sizedtwo-dimensional array to store the entries.#define MAXN 300typedef struct Matrix s {size t R, C;int index[MAXN][MAXN];} Matrix;Of course, this is rather inefficient if we need to create a lot of matrices, since every single matrix structholds MAXN*MAXN ints! For this problem, we only use three matrices, so it?s fine for this use, but we?llsee how to dynamically allocate a matrix in problem matrix2.Input FormatLine 1: Two space-separated integers, RA and CA.Lines 2 . . . RA + 1: Line i + 1 contains CA space-separated integers: row i of matrix A.Line RA + 2: Two space-separated integers, RB and CB .Lines RA + 3 . . . RA + RB + 4: Line i + RA + 3 contains CB space-separated integers: row i of matrix A.Sample Input (file matrix.in)3 21 11 2-4 02 31 2 13 2 1Output FormatLine 1: Two space-separated integers RC and CC , the dimensions of the product matrix C .Lines 2 . . . RC + 1: Line i + 1 contains CC space-separated integers: row i of matrix C .1 MIT 6.S096 Assignment 1, Problem 2If A and B do not have the right dimensions to be multiplied, your output should just be one linecontaining 0 0.Sample Output (file matrix.out)3 34 4 27 6 3-4 -8 -4Output ExplanationWe are given? ? 1 1 1 2 1 A = ? 1 2? and B = 3 2 1 ?4 0so the product is the 3 ? 3 matrix? ? ? ? 1 1 4 4 2 1 2 1 AB = ? 1 2? = ? 7 6 3 ?. 3 2 1 ?4 0 ?4 ?8 ?4

MIT 6.S096 Assignment 1, Problem 2 Problem 2: Matrix Multiplication (matrix)

Given an R A ? C A matrix A and an RB ? CB matrix B , with 1 ? R A , RB , C A , CB ? 300, write a program

that computes the matrix product C = AB . All entries in matrices A and B are integers with absolute

value less than 1000, so you don?t need to worry about over?ow. If matrices A and B do not have the

right dimensions to be multiplied, the product matrix C should have its number of rows and columns

both set to zero.

Use the code at provided in the file matrix.data.zip as a basis for your program ?the input/output

needed is already written for you. Matrices will be stored as a structure

which we?ll typedef

as Matrix. This structure will contain the size of our matrix along with a statically-sized

two-dimensional array to store the entries.

#define MAXN 300

typedef struct Matrix s {

size t R, C;

int index[MAXN][MAXN];

} Matrix; Of course, this is rather inefficient if we need to create a lot of matrices, since every single matrix struct

holds MAXN*MAXN ints! For this problem, we only use three matrices, so it?s ?ne for this use, but we?ll

see how to dynamically allocate a matrix in problem matrix2. Input Format

Line 1: Two space-separated integers, R A and C A . Lines 2 . . . R A + 1: Line i + 1 contains C A space-separated integers: row i of matrix A. Line R A + 2: Two space-separated integers, RB and CB . Lines R A + 3 . . . R A + RB + 4: Line i + R A + 3 contains CB space-separated integers: row i of matrix A. Sample Input (?le matrix.in)

3 2 1 1 1 2 -4 0 2 3 1 2 1 3 2 1 Output Format

Line 1: Two space-separated integers RC and CC , the dimensions of the product matrix C .

Lines 2 . . . RC + 1: Line i + 1 contains CC space-separated integers: row i of matrix C .

1 MIT 6.S096 Assignment 1, Problem 2 If A and B do not have the right dimensions to be multiplied, your output should just be one line

containing 0 0. Sample Output (?le matrix.out)

3 3 4 4 2 7 6 3 -4 -8 -4 Output Explanation

We are given

? ?

1 1

1 2 1

A = ? 1 2? and B =

3 2 1

?4 0

so the product is the 3 ? 3 matrix ? ?

?

?

1 1

4 4 2

1 2 1

AB = ? 1 2?

= ? 7 6 3 ?.

3 2 1

?4 0

?4 ?8 ?4 2 MIT OpenCourseWare

http://ocw.mit.edu 6.S096 Effective Programming in C and C++

IAP 2014 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

**Solution details:**

Answered

QUALITY

Approved

ANSWER RATING

This question was answered on: * Sep 18, 2020 *

* * Solution~0001013921.zip (25.37 KB)

This attachment is locked

We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free copy from our tutoring website www.aceyourhomework.com (Deadline assured. Flexible pricing. TurnItIn Report provided)

##### Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .

#### About this Question

STATUSAnswered

QUALITYApproved

DATE ANSWEREDSep 18, 2020

EXPERTTutor

ANSWER RATING

#### GET INSTANT HELP/h4>

We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

- As a reference for in-depth understanding of the subject.
- As a source of ideas / reasoning for your own research (if properly referenced)
- For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).

#### NEW ASSIGNMENT HELP?

### Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions.
New orders are original solutions *and precise to your writing instruction requirements. Place a New Order using the button below.*

WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN YOUR SET DEADLINE.