(int[][] a, int r1, int c1, int[][] b, int r2, int c2)
| 35 | } |
| 36 | |
| 37 | static void add(int[][] a, int r1, int c1, int[][] b, int r2, int c2){ |
| 38 | if(r1 != r2 || c1 != c2){ |
| 39 | System.out.println("Wrong Input - Addition not possible"); |
| 40 | return; |
| 41 | } |
| 42 | |
| 43 | int[][] sum = new int[r1][c1]; |
| 44 | |
| 45 | for(int i = 0; i < r1; i++){ //row number |
| 46 | for(int j = 0; j < c1; j++){ //column number |
| 47 | sum[i][j] = a[i][j] + b[i][j]; |
| 48 | } |
| 49 | } |
| 50 | System.out.println("Sum of matrix 1 and matrix 2"); |
| 51 | printMatrix(sum); |
| 52 | } |
| 53 | |
| 54 | public static void main(String[] args) { |
| 55 | Scanner sc = new Scanner(System.in); |
no test coverage detected