Page 377 - ComputerScience_Class_11
P. 377
4 {
5 int a[ ][ ] = {{1,3,6,8}, {1,2,3,4}, {6,4,3,8}};
6 int i, j, sum=0;
7 for(i = 0; i<3; i++)
8 {
9 for(j = 0; j<4; j++)
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:
BlueJ: Terminal Window - Java
Options
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
Arrays 375

