AP Computer Science Amediummcq1 pt

Summing only the main diagonal of an n by n array needs

A.one loop adding a[i][i]
B.nested loops over all elements
C.no loop
D.sorting the array

Explanation

Core Concept

Diagonal elements share the index.

Correct Answer

Aone loop adding a[i][i]

More Unit 8: 2D Array practice questions

Try a random question →

Practice more AP Computer Science A questions with full explanations

Practice Unit 8: 2D Array Questions →