#Code:
#include<iostream> using namespace std; class matrix { /* Declaration of two dimensional array */ int a[3][3], b[3][3], ans[3][3]; public: matrix() { cout << "Enter data for first array:" << endl; for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) cin >> a[i][j]; cout << "Enter data for second array:" << endl; for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) cin >> b[i][j]; } void addition() { cout << "After matrix addition" << endl; for(int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { ans[i][j]= a[i][j] + b[i][j]; cout << ans[i][j] << "\t"; } cout << endl; } } }; int main() { cout << "Program for calculation of Matrix Addition" << endl; matrix mtAdd = matrix(); mtAdd.addition(); return 0; }
0 Comment:
Đăng nhận xét
Thank you for your comments!