Coders Packet

C++ Program to Multiply two Matrices using 2D-Vector

By Aalok Kumar

Hello coders, I have implemented a c++ program to calculate the product of two matrices using vectors.

The function multiply(vector,vector) takes two Vectors, A and B as arguments and returns 2D-Vector as multiplication result.

If the dimensions of and B are incompatible for multiplication it returns a Null Vector.

The first line of input takes dimensions of Vector A.

Then it asks for the elements of A.

The next line of input takes the dimensions of Vector B.

Then it asks for the elements of B.

Finally, the product of two Vectors is calculated and returned to the main function.

Here is the sample output of my program:

Enter dimension of matrix A(row col): 2 3
Enter elements of matrix A: 
1 2 3
4 5 6
Enter dimension of matrix B(row col): 3 4
Enter elements of matrix B: 
1 2 3 4
5 6 7 8
9 1 2 3
Output: 
38 17 23 29 
83 44 59 74

Enter dimension of matrix A(row col): 2 2
Enter elements of matrix A: 
5 6
7 8
Enter dimension of matrix B(row col): 2 3
Enter elements of matrix B: 
5 6 7
2 3 4
Output: 
37 48 59 
51 66 81 

 

Download project

Reviews Report

Submitted by Aalok Kumar (Aaloks766626)

Download packets of source code on Coders Packet