-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray4.java
More file actions
43 lines (39 loc) · 1.08 KB
/
array4.java
File metadata and controls
43 lines (39 loc) · 1.08 KB
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
import java.io.*;
class array4
{
public static void main(String args[])throws IOException
{
int i,j,s=0,m,n,s1=0;
BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("ENTER DIMENSIONS OF 1st ARRAY [][]");
m=Integer.parseInt(buf.readLine());
n=Integer.parseInt(buf.readLine());
int a[][]=new int[m][n];
System.out.println("ENTER ELEMENTS OF 1st ARRAY");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=Integer.parseInt(buf.readLine());
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
s=s+a[i][j];
}
System.out.println(" SUM OF THE "+(i+1)+"st ROW IS...."+s);
s=0;
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
s1=s1+a[j][i];
}
System.out.println(" SUM OF THE "+(i+1)+"st COLOUMN IS...."+s1);
s1=0;
}
}
}