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++.

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 Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Submission Instructions Follow the instructions for How to Submit Programming Assignments. Assignmen...

A: the name of the java application is PatternMaker.A string variable firstString is used to store the ...

Q: C++    Write a recursive program that finds out if n is a Fibonacci number or not. The Fibonacci num...

A: The C++ program will follow the given rubrics:Importing header files.Displaying the message to user ...

Q: (select all that apply) In MS Access, to ensure that a grade must be either A, B, C, D or F, whichva...

A: Validation rule:In MS Access, the validation rule used to ensure the grade that must be either A, B,...

Q: Discuss the approaches used to categorize access control methodologies. Discuss the types of control...

A: Answer:Access control:Access control is a security technique that controls the admission of workers ...

Q: whats a string

A: String:A string is a data type used in programming, such as an integer and floating point unitThe st...

Q: Write an application to pre-sell a limited number of cinema tickets. Each buyer can buy as many as 4...

A: Create a java program to pre-sell the cinema ticket.The name of the program is TicketSeller.The maxi...

Q: PLEASE EXPLAIN ALL STEPSPredict the output of the following assembly language program if the input i...

A: Before explaining the difference first user must know about the Assembly languageAssembly language:A...

Q: Problem 1 consists of multiple parts. You should finish one part and ensure that it works before mov...

A: Hello. Since your question has multiple sub-parts, we will solve first three sub-parts for you. If y...

Q: How often does garbage collection run on a DC? Group of answer choices 2 hours 6 hours 12 hours...

A: In this question a user must know about Garbage collection (GC) in the computer system:Garbage colle...