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...
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.
Last edited by mrboolf; Nov 19th, 2008 at 5:55 pm.
Don't know what I was thinking there. I changed it to just greater than and then inbetween the two for loop I made total = 0 again. Both arrays outputted -20 so that seems to be working properly. So by not initializing total to = 0 again after the first array is finished will cause total to equal whatever it was in the first output which would be -40 which I checked and so the counter in the for loop must be written as < and not <= because the element starts at 0? I'm going to look in my book about the indexing
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.