-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatsub.java
More file actions
53 lines (51 loc) · 1.01 KB
/
Copy pathmatsub.java
File metadata and controls
53 lines (51 loc) · 1.01 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
44
45
46
47
48
49
50
51
52
53
import java.util.*;
class matsub
{
public static void main(String args[])
{
int a[][]=new int[50][50];
int b[][]=new int[50][50];
int sub[][]=new int[50][50];
int i,j,row,col;
Scanner s1=new Scanner(System.in);
System.out.println("Enter the no.of rows:\n");
row=s1.nextInt();
System.out.println("Enter the no.of columns:");
col=s1.nextInt();
System.out.println("matrix B:\n");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
System.out.println("Enter the a["+i+"]["+j+"] Element:");
a[i][j]=s1.nextInt();
}
}
System.out.println("matrix B:\n");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
System.out.println("Enter the b["+i+"]["+j+"] Element:");
b[i][j]=s1.nextInt();
}
}
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
sub[i][j]=a[i][j]-b[i][j];
}
}
System.out.println("The sum of the matrices are:");
for(i=0;i<row;i++)
{
System.out.println("\t");
for(j=0;j<col;j++)
{
System.out.println(sub[i][j]+"\t");
}
}
s1.close();
}
}