## Foe89

I'm really not understanding what's going on with the array in this. Here's the question.

The following code totals the values in each of the two arrays. Will the code print the correct total for both arrays?

``````int total = 0;
int count;

for (count = 0; count <= 25; count++)
total += array1[count];
cout << "The total is " << total << endl;

for (count = 0; count <= 25; count++)
total += array2[count];
cout << "The total is " << total << endl;``````

I'm not understanding this at all. Both arrays hold 25 integer elements but they aren't equal to anything, so im just lost here... or maybe it's really simple and I'm thinking too hard about it...

## mrboolf 122

If both array1 and array2 contain 25 elements then you should write your for loops

``for (count = 0; count < 25; count++)``

as arrays of n elements are indexed from 0 to n-1.

Moreover, the second cout will print the sum of all the elements of the second array plus the sum of all the elements of the first array, as long as you don't reset your total variable between the for loops.

EDIT: What do you mean with "they aren't equal to anything" ? Please clarify this.