#include<iostream>
usingnamespace std;
main()
{
int m, n, c, d, first[10][10], second[10][10], sum[10][10],
minus[10][10], times[10][10];
char ans;
cout << "\n\t\t\tWelcome! :)\n";
cout << "\n\tThis is a Matrix Operation Program\n";
cout << endl;
cout << "\n\nEnter the number of rows and columns of matrix: \n";
cout << "[Number of Rows]: ";
cin >> m;
cout << "[Number of Columns]: ";
cin >> n;
cout << endl;
cout << "Enter the elements of first matrix: \n";
cout << endl;
for ( c = 0 ; c < m ; c++ )
for ( d = 0 ; d < n ; d++ )
cin >> first[c][d];
cout << endl;
cout << "Enter the elements of second matrix: \n";
cout << endl;
for ( c = 0 ; c < m ;c++ )
for ( d = 0 ; d < n ; d++ )
cin >> second[c][d];
cout << endl;
for ( c = 0 ; c < m ; c++ )
for ( d = 0 ; d < n ; d++ )
sum[c][d] = first[c][d] + second[c][d];
cout << "Sum of entered matrices: \n";
cout << endl;
for ( c = 0 ; c < m ; c++ )
{
for ( d = 0 ; d < n ; d++ )
cout << sum[c][d] << "\t";
cout << endl;
}
for ( c = 0 ; c < m ; c++ )
for ( d = 0 ; d < n ; d++ )
minus[c][d] = first[c][d] - second[c][d];
cout << "Difference of Entered Matrices: \n";
cout << endl;
for ( c = 0 ; c < m ; c++ )
{
for ( d = 0 ; d < n ; d++ )
cout << minus[c][d] << "\t";
cout << endl;
}
for ( c = 0 ; c < m ; c++ )
for ( d = 0 ; d < n ; d++ )
times[c][d] = first[c][d] * second[c][d];
cout << "Products of Entered Matrices: \n";
cout << endl;
for ( c = 0 ; c < m ; c++ )
{
for ( d = 0 ; d < n ; d++ )
cout << times[c][d] << "\t";
cout << endl;
}
cout << "\nDo you want to solve another matrix?\n";
cout << "[Y] or [N]: ";
cin >> ans;
cout << endl;
if (ans== 'Y')
return main ();
else (ans == 'N');
return 0;
}