-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathArray11.java
More file actions
42 lines (36 loc) · 895 Bytes
/
Array11.java
File metadata and controls
42 lines (36 loc) · 895 Bytes
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
package Day3;
import java.util.Scanner;
public class Array11 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter size of row and column");
int row = sc.nextInt();
int col = sc.nextInt();
System.out.println("Enter the element of matrix");
double[][] mat = new double[row][col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
mat[i][j] = sc.nextInt();
}
}
System.out.println("Double Matrix: ");
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
System.out.print(mat[i][j] + " ");
}
System.out.println();
}
int[] sum = new int[col];
int add = 0;
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
add += mat[j][i];
sum[i] = add;
}
add = 0;
}
for (int i : sum) {
System.out.println("\nSum of Column: " + i);
}
}
}