Question #22994

Write a program that takes values from user to fill a 2 two dimensional array (Matrix) having two rows and five columns and then Hit and add and subtract and divide these two matrixes and store the result in another matrix

Expert's answer

#include<iostream>

using namespace std;

&

int main (){

int a[5][2],b[5][2],s=0;

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

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

cout<<"Enter a["<<i+1<<","<<j+1<<"] : ";

cin>>a[i][j];

}

& }

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

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

cout<<"Enter b["<<i+1<<","<<j+1<<"] : ";

cin>>b[i][j];

}

& }

& cout<<"add :\n";

& for(int i=0; i<5; i++){

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

cout<<a[i][j]+b[i][j]<<" quot;;

}

cout<<endl;

& }

& cout<<"subtract :\n";

& for(int i=0; i<5; i++){

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

cout<<a[i][j]-b[i][j]<<" quot;;

}

cout<<endl;

& }

&

&

cout<<"divide :\n";

& for(int i=0; i<5; i++){

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

cout<<a[i][j]/b[i][j]<<" quot;;

}

cout<<endl;

& }

&

&

&

system("PAUSE"); &

}

using namespace std;

&

int main (){

int a[5][2],b[5][2],s=0;

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

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

cout<<"Enter a["<<i+1<<","<<j+1<<"] : ";

cin>>a[i][j];

}

& }

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

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

cout<<"Enter b["<<i+1<<","<<j+1<<"] : ";

cin>>b[i][j];

}

& }

& cout<<"add :\n";

& for(int i=0; i<5; i++){

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

cout<<a[i][j]+b[i][j]<<" quot;;

}

cout<<endl;

& }

& cout<<"subtract :\n";

& for(int i=0; i<5; i++){

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

cout<<a[i][j]-b[i][j]<<" quot;;

}

cout<<endl;

& }

&

&

cout<<"divide :\n";

& for(int i=0; i<5; i++){

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

cout<<a[i][j]/b[i][j]<<" quot;;

}

cout<<endl;

& }

&

&

&

system("PAUSE"); &

}

Learn more about our help with Assignments: C++

## Comments

## Leave a comment