Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 3 students

2D Array Nested Loop Traversal

< Prev
Next >

What is printed when the following code segment is executed?

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();
}
A

11 12 13 14 15
21 22 23 24
31 32 33
41 42

B

15 14 13 12 11
25 24 23 22
35 34 33
45 44

C

15 14 13 12 11
25 24 23 22 21
35 34 33 32 31
45 44 43 42 41

D

15 14 13 12
25 24 23
35 34
45

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1bommasam00013 0m 54s 26
#2demosolasis111 1m 20s 20
#3y.seong202711 2m 47s -67
Items per page:
10
1 – 3 of 3
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|FAQ