C++ Program to Check Multiplicability of Two Matrices

This is a C++ Program to check multiplicability of two matrices. Multiplicability says, if the column if the first matrix matches exactly with the row of the second matrix.

Here is source code of the C++ Program to Check Multiplicability of Two Matrices. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.

  1. #include<conio.h>
  2. #include<iostream>
  3. #include<math.h>
  4.  
  5. using namespace std;
  6.  
  7. int main(int argc, char **argv)
  8. {
  9.     cout<<"Enter the dimension of the matrix:\n ";
  10.     int rowA;cin>>rowA;
  11.     int colA;cin>>colA;
  12.  
  13.     cout<<"Enter the dimension of the other matrix:\n ";
  14.     int rowB;cin>>rowB;
  15.     int colB;cin>>colB;
  16.  
  17.     if(colA == rowB)
  18.     {
  19.         cout<<"Matrices are multipilcable";
  20.     }
  21.     else
  22.     {
  23.         cout<<"Matrices are not multipilcable";
  24.     }
  25. }

Output:

$ g++ MultiplicabilityOfMatrix.cpp
$ a.out
 
Enter the dimension of the matrix:
 2 4
Enter the dimension of the other matrix:
 2 5
Matrices are not multipilcable
 
Enter the dimension of the matrix:
 4 5
Enter the dimension of the other matrix:
 5 6
Matrices are multipilcable

Sanfoundry Global Education & Learning Series – 1000 C++ Programs.

advertisement
advertisement

Here’s the list of Best Books in C++ Programming, Data Structures and Algorithms.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.