You are on page 1of 2

#include<iostream>

using namespace std;

int main(){

int x[100][100], x1[100][100], z, e;

cout << "\nEnter rows for Matrix 1: "; cin >> z;

cout << "\nEnter column for Matrix 1: "; cin >> e;

cout << "\nEnter rows for Matrix 2: " <<z<<endl;

cout << "\nEnter column for Matrix 2: " <<z;

cout <<endl <<endl;

cout << "Enter elements in Matrix 1: ";

for (int i=0; i<z; i++){

for (int j=0; j<e; j++){

cin >> x[i][j];

cout << "\nEnter elements in Matrix 2:";

for (int i=0; i<z; i++){

for (int j=0; j<e; j++){

cin >> x1[i][j];

cout << "\nElements in Matrix 1: " <<endl;

for (int i=0; i<z; i++){

for (int j=0; j<e; j++){

cout << x[i][j] << "\t";

}
cout <<endl;

cout << "\nElements in Matrix 2: " <<endl;

for (int i=0; i<z; i++){

for (int j=0; j<e; j++){

cout << x1[i][j] << "\t";

cout <<endl;

cout << "\nSum of the Matrices: " <<endl;

for (int i=0; i<z; i++){

for (int j=0; j<e; j++){

cout << x[i][j] + x1[i][j] << "\t";

cout <<endl;

return 0;

You might also like