Your code sets
total = array[0] + array[1] -> 9
then
total = array[1] + array[2] -> 6
then
total = array[2] + array[3] -> 9
then
total = array[3] + array[4] -> undefined behavior
which of course not what you want. You ask
I know that I need to store the value
of the sum into a variable but how do
I make the variable loop back to be
added to the next number in the array.
Well, the variable is total, and you want to add it to the next number in the array; that's simply
total = total + array[n]
(or total += array[n]).
All that remains is to initialize total = 0 so that the first add (total = total + array[0]) sets total to array[0] rather than some undefined value.