2D Array Nested Loop Traversal
Consider the following code segment.
int[][] points = {{11, 12, 13, 14, 15},
{21, 22, 23, 24, 25},
{31, 32, 33, 34, 35},
{41, 42, 43, 44, 45}};
for (int row = 0; row < points.length; row++)
{
for (int col = points[0].length - 1; col >= row; col--)
{
System.out.print(points[row][col] + " ");
}
System.out.println();
}
What is printed when this code segment is executed?
A
15 14 13 12 11
25 24 23 22 21
35 34 33 32 31
45 44 43 42 41
B
11 12 13 14 15
21 22 23 24
31 32 33
41 42
C
15 14 13 12 11
25 24 23 22
35 34 33
45 44
D
15 14 13 12
25 24 23
35 34
45
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE