Page 335 - Cs_withBlue_J_C11_Flipbook
P. 335
10 {
11 System.out.print (a[i][j]+" ");
12 }
13 System.out.println ();
14 }
15 for(i = 0;i<3;i++)
16 {
17 sum = 0;
18 for(j = 0;j<4;j++)
19 {
20 sum = sum+a[i][j];
21 }
22 System.out.println ("Row "+(i+1)+" total is: "+sum);
23 }
24 }
25 }
The output of the preceding program is as follows:
1 3 6 8
1 2 3 4
6 4 3 8
Row 1 total is: 18
Row 2 total is: 10
Row 3 total is: 21
Program 11 Write a program in Java to store the numbers in a 3 × 3 matrix and assign the Transposed
matrix in another array and display it. Transpose means interchanging of the rows and
columns.
Original matrix
1 2 3
4 5 6
7 8 9
Transposed matrix
1 4 7
2 5 8
3 6 9
1 import java.util.*;
2 class array_double_transpose
333
Arrays 333

