| 251 | } |
| 252 | |
| 253 | void product() |
| 254 | { |
| 255 | system("cls"); |
| 256 | cout << "\t\tMULTIPLY TWO MATRICES\n"; |
| 257 | cout << "\tNOTE: Rows 1 = Column 2 \n"; |
| 258 | cout << "Please input details for the First Matrix: \n"; |
| 259 | int row_input, col_input; |
| 260 | cout << "Rows (max 5): "; |
| 261 | cin >> row_input; |
| 262 | cout << "Columns (max 5): "; |
| 263 | cin >> col_input; |
| 264 | int a[5][5]; |
| 265 | cout << "Now input elements of First Matrix: "; |
| 266 | if (row_input > 0 && row_input <= 5 && col_input > 0 && col_input <= 5) |
| 267 | { |
| 268 | for (int row = 0; row < row_input; row++) |
| 269 | { |
| 270 | for (int col = 0; col < col_input; col++) |
| 271 | { |
| 272 | cin >> a[row][col]; |
| 273 | } |
| 274 | } |
| 275 | cout << "First Matrix: \n"; |
| 276 | for (int row = 0; row < row_input; row++) |
| 277 | { |
| 278 | for (int col = 0; col < col_input; col++) |
| 279 | { |
| 280 | cout << a[row][col] << " "; |
| 281 | } |
| 282 | cout << endl; |
| 283 | } |
| 284 | } |
| 285 | else |
| 286 | { |
| 287 | system("cls"); |
| 288 | cout << "Please input valid numbers from 1 to 5 ! " << endl; |
| 289 | read_display(); |
| 290 | } |
| 291 | // for the second matrix |
| 292 | cout << endl; |
| 293 | cout << "Please input details for the Second Matrix: \n"; |
| 294 | int row_input2, col_input2; |
| 295 | cout << "Rows (max 5): "; |
| 296 | cin >> row_input2; |
| 297 | cout << "Columns (max 5): "; |
| 298 | cin >> col_input2; |
| 299 | int b[5][5]; |
| 300 | cout << "Now input elements of Second Matrix: "; |
| 301 | if (row_input2 > 0 && row_input2 <= 5 && col_input2 > 0 && col_input2 <= 5) |
| 302 | { |
| 303 | for (int row = 0; row < row_input2; row++) |
| 304 | { |
| 305 | for (int col = 0; col < col_input2; col++) |
| 306 | { |
| 307 | cin >> b[row][col]; |
| 308 | } |
| 309 | } |
| 310 | cout << "Second Matrix: \n"; |
no test coverage detected