I want to die

How do I add in a vector, the sum of consecutive numbers, between these numbers. It's not HOMEWORK. I'm trying to learn. This is what i got so far. (I get
>"System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'"
for some reason. I've tried everything to fix it in the past 2 hours or more)

// suppose we set 5 values for vector : {3,4,5,6,7}. // It'll go through the vector till index [4]. It doesnt even get to the part where it should do the sum and replace the numbers and etc. I dont understand why it still goes through the IF condition if it doesn't respect it.

j = 4
j < vec.length is true
vec[j + 1] is out of bounds

i know that... but how should i fix it? I dont know any other way around... and i gotta use basic stuff to finish this, no special functions or anything (Array.Sort, count, etc... whatever)

your code looks fucking ugly

thank you im dying.

please help....

>How do I add in a vector, the sum of consecutive numbers, between these numbers.
can you explain this? what should [3, 4, 5, 6, 7] return? [3, 7, 4, 9, 5, 11, 6, 13, 7]?

vec[j+1] throws the exception
you have to check if j+1 is < vec.length

precisely.

1. loop array
2. print number at index i
3. check if index i + 1 < array length
4, print number + next number


or instad of print just add it to a new array