1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | #include <iostream> using namespace std; class matrix{ private: int **mat; int row; int col; public: matrix(){ } matrix(int row,int col) { this->row = row; this->col = col; mat = new int* [row]; int i,j; for(i=0;i<row;i++) { mat[i] = new int[col]; for(j=0;j<col;j++) { mat[i][j] = 0; } } } void getData() { int i,j; cout<<"enter values: "; for(i=0;i<row;i++) { mat[i] = new int[col]; for(j=0;j<col;j++) { cin>>mat[i][j]; } } } int getElement(int row,int col) { return mat[row][col]; } void setElement(int value,int row,int col) { mat[row][col] = value; } void printData(){ for(int i=0;i<row;i++){ for(int j=0;j<col;j++) { cout<< mat[i][j]<<" "; } cout<<endl; } } matrix add(matrix p){ matrix temp(row,col); int x; for(int i=0;i<row;i++){ //cout<<"pass\n"; for(int j=0;j<col;j++) { x = p.getElement(i,j)+mat[i][j]; //cout<<"col pass\n"; temp.setElement(x,i,j); } } return temp; } }; int main() { matrix m(2,2),n(2,2),o(2,2); m.getData(); n.getData(); m.printData(); cout<<endl; n.printData(); cout<<endl; o = m.add(n); //cout<<"hello\n"; o.printData(); } |
- ADP IT Past Papers
- 2017 Past Papers ADP
- Introduction To Computing
- Islamic Studies
- Calculus I
- Calculus-II
- Mechanics Waves And Motion
- Pakistan Studies
- Electricity And Magnetism
- Programming Fundamentals
- 2018 Past Papers ADP
- Internet Programming
- Operating System
- Database System
- Communication Skills
- Calculus II
- Discrete Mathmatics
- Software Engineering
- Pakistan Studies
- Programming Fundamentals 1
- Programming Fundamentals 2
- Object Oriented Programming
- Digital Logic And Design
- Data Structures and Algorithms
- Electricity And Magnetism
- Enterprise Application Development
- Probability and Statisistics
Note: Watch Video How To Download Given Blow ⤈⤈⤈
Subscribe to:
Post Comments (Atom)
PPSC Imtiaz Shahid Books PPSC
Sql Solved Queries
Subscribe at Youtube
Featured post
Course Outline BSIT 2 year Associate Degree Program All Semester
Course Outline BSIT 2 year Program First Semester Outline Second Semester Outline Third Semester Outline ...
Post a Comment