Traversing 2D Arrays

AP Computer Science A· difficulty 4/5

For m = {{1,2,3},{4,5,6},{7,8,9}}, what is the sum of m[i][i] for i=0..2?

  • A

    9

  • B

    15

    check_circle
  • C

    12

  • D

    6

Explanation

1 + 5 + 9 = 15 (main diagonal).

Want 10 more like this — adaptive to your weak spots?

Related questions