Untitled
unknown
plain_text
2 months ago
712 B
5
Indexable
// 2D matrix addition #include <iostream> using namespace std; int main() { int a[2][2]; int b[2][2]; int c[2][2]; cout<<"elements of array"<<endl; for (int i=0;i<2;i++) { for (int j=0;j<2;j++) { cin>>a[i][j]; } } cout<<"elements of array"<<endl; for (int i=0;i<2;i++) { for (int j=0;j<2;j++) { cin>>b[i][j]; } cout<<endl; } cout<<"addition matrix"<<endl; for (int i=0;i<2;i++) { for (int j=0;j<2;j++) { c[i][j]=a[i][j]+b[i][j]; cout<<c[i][j]<<" "; } cout<<endl; } return 0; }
Editor is loading...
Leave a Comment