#include using namespace std;
int main() { int choice; cout << "Enter 1 for single matrix operations or 2 for two matrix
operations: "; cin >> choice;
if (choice == 1) {
int r, c, mat[10][10], sum = 0;
cout << "Enter rows and columns: ";
cin >> r >> c;
cout << "Enter matrix: ";
for (int i = 0; i < r; i++)
for (int j = 0; j < c; j++) {
cin >> mat[i][j];
sum += mat[i][j];
}
cout << "Total Sum: " << sum << "\n";
}
else if (choice == 2) {
int n, A[10][10], B[10][10], sum[10][10], prod[10][10] = {};
cout << "Enter size of square matrix: ";
cin >> n;
cout << "Enter first matrix: ";
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
cin >> A[i][j];
cout << "Enter second matrix: ";
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
cin >> B[i][j];
cout << "Matrix Addition:\n";
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
sum[i][j] = A[i][j] + B[i][j];
cout << sum[i][j] << " ";
}
cout << "\n";
}
cout << "Matrix Multiplication:\n";
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int k = 0; k < n; k++)
prod[i][j] += A[i][k] * B[k][j];
cout << prod[i][j] << " ";
}
cout << "\n";
}
}
return 0;