Answer:
Add the following lines of code to the already existing code segment
<em>for (i = 0; i < SCORES_SIZE-1; ++i) { </em>
<em> bonusScores.at(i) = bonusScores.at(i) + bonusScores.at(i+1);</em>
<em> }</em>
Explanation:
To do the task in the question, we have to iterate through the vector from the first element i.e. element at index 0 to the second to the last element; i.e. element at last index - 1
We then add each element in this iteration with the next.
This iterates through the vector from 0 to SCORES_SIZE - 1
<em>for (i = 0; i < SCORES_SIZE-1; ++i) { </em>
<em>This adds each vector element with the next</em>
<em> bonusScores.at(i) = bonusScores.at(i) + bonusScores.at(i+1);</em>
<em> }</em>
The above should be added before
<em>for (i = 0; i < SCORES_SIZE; ++i) { </em>
<em> cout << bonusScores.at(i) << " "; </em>
<em>}</em>
<em />
<em>Also, I've made other modifications to the program.</em>
- <em>Proper import of header files</em>
- <em>Proper declaration of vector bonusScores</em>
<em />
<em>See attachment for complete source code</em>