-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRowColumnSum.java
More file actions
33 lines (30 loc) · 921 Bytes
/
Copy pathRowColumnSum.java
File metadata and controls
33 lines (30 loc) · 921 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
import java.util.*;
import java.lang.*;
public class RowColumnSum {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of rows and coloumns");
int n = sc.nextInt();
int m = sc.nextInt();
int arr[][] = new int[n][m];
for(int i = 0;i<n;i++){
for(int j = 0;j<m;j++){
arr[i][j] = sc.nextInt();
}
}
for(int i = 0;i<n;i++){
int rowsum = 0;
for(int j = 0;j<m;j++){
rowsum += arr[i][j];
}
System.out.println("row Sum "+i+" :"+rowsum);
}
for(int i = 0;i<m;i++){
int colusum = 0;
for(int j = 0;j<n;j++){
colusum += arr[j][i];
}
System.out.println("coloumn sum "+i+ ": "+colusum);
}
}
}