You need a method to add
void add(int a[][maxCols], int b[][maxCols], int res[][maxCols])
{
int row, col;
for (row = 0; row < maxRows; row++) {
for (col = 0; col < maxCols; col++) {
res[row][col] = a[row][col] + b[row][col];
}
}
}
and create 2 matrix in main
, add them and show the result:
int main() {
int a[maxRows][maxCols];
int b[maxRows][maxCols];
int result[maxRows][maxCols];
readMatrix(a);
readMatrix(b);
cout << "\n\n" << "The matrix is: " << '\n';
displayMatrix(a);
cout << "\n\n" << "The matrix is: " << '\n';
displayMatrix(b);
add(a, b, result);
cout << "\n\n" << "The result matrix is: " << '\n';
displayMatrix(result);
}
1
solved in c++ how to shows result of matrix with the additions [closed]