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

Summing Elements in a 2D Array

< Prev
Next >

Consider the following code segment.

int[][] arr = {{1, 2, 3, 4},
               {5, 6, 7, 8},
               {9, 10, 11, 12}};

int sum = 0;
for (int[] x : arr)
{
    for (int y = 0; y < x.length - 1; y++)
    {
        sum += x[y];
    }
}

What is the value of sum after the code segment has been executed?

A

54

B

68

C

36

D

78

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
#1kaisuki12 0m 00s 90
#2midnightasdark11 0m 22s 78
#3dobaonam838612 0m 48s 42
#4mullameh00112 1m 16s 14
#5geethasailaja01 0m 54s -64
#6ajcantuwilson032512 3m 47s -137
#7varunrajaram101 2m 22s -152
#8y.seong202702 3m 20s -220
#9ponneban00011 15m 07s -807
#10psak1211 15m 45s -845
Items per page:
10
1 – 10 of 11
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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