I understand how to sum all the numbers in an integer array but how can I sum up just half of the numbers in the array like just the top half or just the bottom half? Any suggestions would help, Thank you!

Printable View

- 04-16-2007quiet_forever(newb) Summing half of an array
I understand how to sum all the numbers in an integer array but how can I sum up just half of the numbers in the array like just the top half or just the bottom half? Any suggestions would help, Thank you!

- 04-16-2007laserlight
Well... how do you sum all the numbers an integer array? Show your code snippet.

- 04-16-2007quiet_forever
something like this:

Code:

int SumofAll (int Array[], int size)

{

int total = 0;

for (int i = 0; i < size; i++)

total+= Array [i];

return total;

}

- 04-16-2007Salem
There is no difference between

total = SumofAll( myArray, 10 );

and

total = SumofAll( &myArray[0], 10 );

Can you adjust the index and count now?