Write a loop that sets each array element to the sum of itself and the next element, except for the last element which stays the same. Be careful not to index beyond the last element.   Ex:Initial scores: 10, 20, 30, 40   Scores after the loop: 30, 50, 70, 40   The first element is 30 or 10 + 20, the second element is 50 or 20 + 30, and the third element is 70 or 30 + 40. The last element remains the same. #include <iostream>using namespace std; int main() {const int SCORES_SIZE = 4;int bonusScores[SCORES_SIZE];int i; for (i = 0; i < SCORES_SIZE; ++i) {cin >> bonusScores[i];} /* Your solution goes here */ for (i = 0; i < SCORES_SIZE; ++i) {cout << bonusScores[i] << " ";}cout << endl; return 0;} Please help me with this issue using c++.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 5GZ
icon
Related questions
Question
Write a loop that sets each array element to the sum of itself and the next element, except for the last element which stays the same. Be careful not to index beyond the last element.
 
Ex:Initial scores: 10, 20, 30, 40
 
Scores after the loop: 30, 50, 70, 40
 
The first element is 30 or 10 + 20, the second element is 50 or 20 + 30, and the third element is 70 or 30 + 40. The last element remains the same.

#include <iostream>
using namespace std;

int main() {
const int SCORES_SIZE = 4;
int bonusScores[SCORES_SIZE];
int i;

for (i = 0; i < SCORES_SIZE; ++i) {
cin >> bonusScores[i];
}

/* Your solution goes here */

for (i = 0; i < SCORES_SIZE; ++i) {
cout << bonusScores[i] << " ";
}
cout << endl;

return 0;
}

Please help me with this issue using c++.

 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,