#include using namespace std; const int SIZE = 5; int main() { int i, j, k, n; int A[SIZE][SIZE]; int B[SIZE][SIZE]; int C[SIZE][SIZE]; // Initialise all entries to zero for (i = 0; i < SIZE; i++) { for (j = 0; j < SIZE; j++) { A[i][j] = 0; B[i][j] = 0; } } // A and B are square matrices, read in the number of rows and columns cout << "How many rows and columns in A and B?" << endl; cout << "(Note: maximum " << SIZE << ")" << endl; cin >> n; // Read values for the elements of A (row by row): for (i = 0; i < n; i++) { cout << "A Row " << i << " (enter " << n << " values)" << endl; for (j = 0; j < n; j++) { cin>>A[i][j]; } } // Read values for the elements of B (row by row): for (i = 0; i < n; i++) { cout << "B Row " << i << " (enter " << n << " values)" << endl; for (j = 0; j < n; j++) { cin >> B[i][j]; } } // Calculate the sum of the matrices A and B cout << "The sum of A and B is:" << endl; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { C[i][j] = A[i][j] + B[i][j]; cout << C[i][j] << " "; } cout << endl; } return (0); }