3x3 matrix addition using arrays

#include<iostream>
using namespace std;
int matr[3][3];
int matr2[3][3];
int matr3[3][3];
int main(){

cout<<"enter matrix values of 3 x 3 matrix "<<endl;

for(int x=0;x<=2;x++){
for(int y=0;y<=2;y++){
cout<<"["<<x<<"]"<<"["<<y<<"] = ";
cin>>matr[x][y];
}
}

cout<<"enter matrix values of another  3 x 3 matrix "<<endl;
for(int x=0;x<=2;x++){
for(int y=0;y<=2;y++){
cout<<"["<<x<<"]"<<"["<<y<<"] = ";
cin>>matr2[x][y];
}
}

for(int x=0;x<=2;x++){
for(int y=0;y<=2;y++){
matr3[x][y]=matr[x][y]+matr2[x][y];
}
}
cout<<endl;

for(int x=0;x<=2;x++){
for(int y=0;y<=2;y++){
cout<<"  "<<matr3[x][y];
}
cout<<endl;
}
}





Previous
Next Post »

Comments:

Disqus Shortname