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

2D Array Traversal and Summation

< Prev
Next >

What is the value of sum after the following code segment is executed?

int[][] matrix = {
    {1, 2, 3, 4},
    {5, 6, 7, 8},
    {9, 10, 11, 12}
};
int sum = 0;
for (int i = 0; i < matrix.length; i++) {
    for (int j = 0; j < matrix[i].length; j++) {
        if (matrix[i][j] % 3 == 0) {
            matrix[i][j] /= 3;
        }
        sum += matrix[i][j];
    }
}
A

50

B

56

C

58

D

54

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
#1mtanarupi22 0m 00s 200
#2deltasmpserver11 0m 00s 100
#3kaisuki11 0m 00s 100
#4midnightasdark13 0m 41s 39
#5y.seong202702 5m 45s -365
Items per page:
10
1 – 5 of 5
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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