Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ please 2. Write a program that can be used to multiply two matrice:s A, and B and store them in a matrix C.

In C++ please
image text in transcribed
2. Write a program that can be used to multiply two matrice:s A, and B and store them in a matrix C. In order to do that, first declare three arrays (2-D) (A, B, C) of size maximum size 20 x 20. For matrix multiplication, the general rule is if matrix A has m rows and n cols, then matrix B must have n rows and p columns. The size of C then will be m rows and p columns The algorithm for writing this code is as given below Declare m, n, p Get user input for matrix A (values of m and n) Then Get user input for number of column for B (p) Write nested loop (first for row and then for column) to get values for A[i]i] Row no-i, col no-j, and i varying from 0 to (m-1) and j varying from 0 to (n-1) * Write nested loop similarly for B[i][j], i varying from 0 to (n-1) and j varying from 0 to (p-1) . Initialize all values for C[i][J], for i varying from 0 to (m-1) and j varying from 0 to (p-1) to 0 Write a nested loop with i varying from 0 to (m-1), and j varying from 0 to (p-1) and inside that k varying from 0 to (n-1) and use the following formula for C Finally Display C row by row (i.e. display C[i][j], for i from 0 to (m-1) and j varying from 0 to (p-1)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions