Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
80 lines (66 loc) · 1.62 KB

File metadata and controls

80 lines (66 loc) · 1.62 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package chapter06;
import java.util.Scanner;
public class J06_19{
public static void main(String[] args){
int Matrix1[][] = new int[3][3];
int Matrix2[][] = new int[3][3];
int Matrix3[][] = new int[3][3];
int i, j, k;
int Temp1[] = new int[9];
int Temp2[] = new int[9];
Scanner S = new Scanner(System.in);
try {
System.out.println("\nEnter Elements of Matrix1 (9 integer elements) : ");
for (i=0; i<9; i++)
{
Temp1[i] = S.nextInt();
for (j=0; j<3; j++)
{
for(k=0; k<3; k++)
Matrix1[j][k] = Temp1[i];
}
}
System.out.println("\nEnter Elements of Matrix2 (9 integer elements) : ");
for (i=0; i<9; i++)
{
Temp1[i] = S.nextInt();
for (j=0; j<3; j++)
{
for(k=0; k<3; k++)
Matrix2[j][k] = Temp2[i];
}
}
} // end of try block
catch(Exception E) {
System.out.print("\nError in input! Program terminated.");
System.exit(0);
}
System.out.println("Elements of the Matrix1 is :");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
System.out.print(Matrix1[i][j]+ " ");
System.out.println();
}
System.out.println("Elements of the Matrix2 is :");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
System.out.print(Matrix2[i][j]+ " ");
System.out.println();
}
for( i=0; i<3; i++)
{ // Addition done here
for(j=0; j<3; j++)
Matrix3[i][j] = Matrix1[i][j]+Matrix2[i][j];
}
System.out.println("Addition of the Matrices is : ");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
System.out.print(Matrix3[i][j]+ " ");
System.out.println();
}
S.close();
} // End of main()
} // End of class
Morty Proxy This is a proxified and sanitized view of the page, visit original site.