The values variable references a two-dimensional double array with 10 rows and 20 columns. Write code that sums all the elements in the array and stores the sum in the variable total. double total = 0;
for( int i = 0; i < 10; i++)
for( int j = 0; j < 20; j++)
total = total + values [i] [j];

Respuesta :

Yes, the code you provided will correctly sum all the elements in the two-dimensional array values and store the result in the variable total.

How does this works?

The code uses a nested loop structure, with the outer loop iterating over the rows (indexed by i) and the inner loop iterating over the columns (indexed by j).

For each iteration of the inner loop, the value of the element at the current row and column is added to the total variable.

This continues until all the elements in the array have been processed, at which point total will hold the sum of all the elements.

To Know More About nested loop, Check Out

https://brainly.com/question/13971698

#SPJ4

ACCESS MORE