Matrix Multiplication in C++

Posted By: Java Examples - 9:13 PM

Share

& Comment

Matrix multiplication in c language: c program to multiply matrices (two dimensional array), this program multiplies two matrices which will be entered by the user. Firstly user will enter the order of a matrix. If the entered orders of two matrix is such that they can't be multiplied then an error message is displayed on the screen. You have already studied the logic to multiply them in Mathematics. Matrices are frequently used while doing programming and are used to represent graph data structure, in solving system of linear equations and many more.
Algorithm:

Multiplication of two matrix:

Rule: Multiplication of two matrix is only possible if first matrix has size m X n and other matrix has size n x r. Where m, n and r are any positive integer.

Multiplication of two matrices is defined as





Where 1 ≤ i ≤ m and 1 ≤ j ≤ n

For example:
Suppose two matrix A and B of size of 2 x 2 and 2 x 3 respectively:



C++ Code is given bellow :


Output of this program :


Enter the number of rows and columns of A matrix

row = 2
coloum = 3
Enter the elements of A matrix
2
5
8
6
3
4
Enter the number of rows and columns of B matrix
row = 3
coloum = 4
Enter the elements of B matrix
2
5
6
4
5
2
1
3
5
7
8
9
Product of entered matrices:-
69      76      81      95
47      64      71      69

 Date - 1/25/2013-@author ACHCHUTHAN -cpp90.blogspot.com
Press any key to continue . . .

About Java Examples

I’m passionate about Web Development and Programming and I go to extreme efforts to meet my passion. I’m a believer of learning the fundamentals first. I try to understand everything little bit more than the average.

0 comments :

Post a Comment

Copyright © 2016 C++ Examples ACHCHUTHAN.ORG. Designed by Templateism .