// Let's print out matrix one and matrix 2.

// Multiplication My Version
#include <iostream>
 
using namespace std;

void print_matrix(int M[10][10], int m, int n)
/**
 Print out a square matrix of size s, max size 10.
 */
{
   for (int i = 0; i < m; ++i)
   {
      for (int j = 0; j < n; ++j) 
      {
         cout << M[i][j] << "\t";
      }
      cout << endl;
   }
}

int main()
{
   int m, n, c, d, o, p, first[10][10], second[10][10], mult[10][10];
 
   cout << "Enter the number of rows and columns of matrix 1 ";
   cin >> m >> n;
   cout << "Enter the number of rows and columns of matrix 2 ";
   cin >> o >> p;
   
   cout << "Enter the elements of first matrix\n";
 
   for (  c = 0 ; c < m ; c++ ) 
   {
      for ( d = 0 ; d < n ; d++ ) 
      {
         cin >> first[c][d];
      }
   }
 
   cout << "Enter the elements of second matrix\n";
 
   for ( c = 0 ; c < o ;c++ ) 
   {
      for ( d = 0 ; d < p ; d++ ) 
      {
            cin >> second[c][d];
      }
    }
    cout << "First Matrix:" << endl;
    print_matrix(first, m, n);
    cout << endl << "Second Matrix:" << endl;
    print_matrix(second, o, p);
   //mult
   if(n==o)
   {
 
       for ( c = 0 ; c < m ; c++ )
       {
     
          for ( d = 0 ; d < p ; d++ )
          {
                mult[c][d]=0;
          
              for(int k=0;k<n;k++)
              {
         
               mult[c][d] += first[c][k] * second[k][d];
              } 
           }
       }
    }
   else {
       cout<<"Multiplication not possible";
   }
   cout << "Product of entered matrices:-\n";
 
   print_matrix(mult, m, o);

   return 0;
}