Matrix Multiplication
Matrix is 2D array in computer science. Take user input for row and colum for matrix A and matrix B. Column count of matrix A should match to row count of matrix B else we should return. Allocate two 2D dynamic array A and B, first allocate pointes for row elemnets and then allocate columns elements and assign each column pointers to row list. Now populate elements for matrix A with user input. Then do the same for matrix B. Now take element[0,0] from A and B and multiply row elements of A to column elements of B and sum up. This sum is the resultant element for position [0,0]. Repeat the same for rest of all positions individually. Thus the resultant matrix is formed.
Source Code
Output
== Matrix Multiplication Demo == Matrix A has rows : 2 Matrix A has columns : 2 Matrix B has rows : 2 Matrix B has columns : 3 Matrix A Element [0][0] : 1 Element [0][1] : 2 Element [1][0] : 3 Element [1][1] : 4 Matrix B Element [0][0] : 5 Element [0][1] : 6 Element [0][2] : 7 Element [1][0] : 8 Element [1][1] : 9 Element [1][2] : 10 Matrix A | 01 02 | | 03 04 | Matrix B | 05 06 07 | | 08 09 10 | Matrix A x B | 21 24 27 | | 47 54 61 |
About our authors: Team EQA
You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Calculate weighted average