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!
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!
Well... how do you sum all the numbers an integer array? Show your code snippet.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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; }
There is no difference between
total = SumofAll( myArray, 10 );
and
total = SumofAll( &myArray[0], 10 );
Can you adjust the index and count now?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.