1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Vladimir [108]
3 years ago
9

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.
SAMPLE OUTPUT:
#include
int main(void) {
const int SCORES_SIZE = 4;
int bonusScores[SCORES_SIZE];
int i = 0;
bonusScores[0] = 10;
bonusScores[1] = 20;
bonusScores[2] = 30;
bonusScores[3] = 40;
/* Your solution goes here */
for (i = 0; i < SCORES_SIZE; ++i) {
printf("%d ", bonusScores[i]);
}
printf("\n");
return 0;
}
Computers and Technology
1 answer:
OlgaM077 [116]3 years ago
6 0

Answer:

Replace /* Your solution goes here */  with the following lines of code

for(i = 0;i<SCORES_SIZE-1;i++)

{

bonusScores[i]+=bonusScores[i+1];

}

Explanation:

The above iteration starts from the index element (element at 0) and stops at the second to the last element (last - 1).

Using an iterative variable, i

It adds the current element (element at i) with the next element; element at i + 1.

The full code becomes

#include<iostream>

using namespace std;

int main(void) {

const int SCORES_SIZE = 4;

int bonusScores[SCORES_SIZE];

int i = 0;

bonusScores[0] = 10;

bonusScores[1] = 20;

bonusScores[2] = 30;

bonusScores[3] = 40;

for(i = 0;i<SCORES_SIZE-1;i++)

{

bonusScores[i]+=bonusScores[i+1];

}

/* Your solution goes here */

for (i = 0; i < SCORES_SIZE; ++i) {

printf("%d ", bonusScores[i]);

}

printf("\n");

return 0;

}

See attachment for .cpp file

Download cpp
You might be interested in
What is the purpose of extent in lines in engineering drawing
Blizzard [7]

Answer:

Extension lines are used to indicate the extension of a surface or point to a location preferably outside the part outline.

Explanation:

7 0
3 years ago
Which of the following are the differences between DDR3 SDRAM and DDR2 SDRAM? DDR3 transfers data at twice the rate of DDR2. DDR
Free_Kalibri [48]

Answer:

DDR3 SDRAM having twice rate of data transferring as compared to DDR2 SDRAM both have 240 pin connection. DDR3 memory power consumption is 40 % less as compared to DDR2. both are transfers data on a 64 data bits wide bus. The physical difference occur in both type a cut is present at bottom along pin in DDR2 it is occur probably in center and In DDR3 it is occur at left  through center.

7 0
3 years ago
The compiler decides which version of a polymorphic method to call at compile time
astra-53 [7]

Answer:

T

Explanation:

Hope it's help.you.

plz Mark me as brinliest

Thank you

8 0
3 years ago
What does XML do with a data wrapped in the tags?
Arlecino [84]

Answer:

Especificación para diseñar lenguajes de marcado, que permite definir etiquetas personalizadas para descripción y organización de datos. ¿Para que sirve XML? Representar información estructurada en la web (todos documentos), de modo ... Las etiquetas se definen para crear los documentos, no tienen un significado

Explanation:

5 0
3 years ago
Why electronic file organization is a key skill for today's workplace ​
Rufina [12.5K]
(I am not sure what you are asking since question is not specific enough),
I am assuming you are asking why organizing a file on a computer is a key skill-

It is because today’s workplace should have as much organization as possible for a steady workplace and work environment, making needed files easy to access.
3 0
3 years ago
Other questions:
  • If a 120 V appliance requires 15 A to operate, what is the resistance of the appliance?
    10·1 answer
  • Which tool allows multiple users to dynamically update a document at the same time? Question 3 options: Google Docs OneDrive Exc
    14·1 answer
  • The number of bytes in an array is always a multiple of the number of ____ in an array.
    6·1 answer
  • Open Comments.java and write a class that uses the command window to display the following statement about comments:
    8·1 answer
  • Your company wants to use an IoT device but wants to make sure it does not interfere with other RF devices that use the 2.4 GHz
    12·1 answer
  • 1.Can ICTs be innovatively used in the absence of minimum literacy levels among the poor?
    5·1 answer
  • Conner has located a research source that is sponsored by a pharmaceutical company. Based on the sponsorship, Conner must be car
    8·1 answer
  • ​what is the difference between a normal mouse and trackball? What do you think. ​​​​
    7·1 answer
  • in a client server architecture what are the three propoerties of a client and three properties of a server
    12·1 answer
  • ____ takes care of the transport between machines. but it is unreliable, and there is no guarantee that any given packet will ar
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!