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
Daniel [21]
3 years ago
11

Write a for loop that sets each array element in bonusScores to the sum of itself and the next element, except for the last elem

ent which stays the same. Be careful not to index beyond the last element. Ex: If bonusScores = [10, 20, 30, 40], then after the loop bonusScores = [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. function bonusScores = CombineScores(numberScores, userScores) % numberScores: Number of scores in array bonusScores % bonusScores: User defined array of test scores % Write a for loop that sets each array element in bonusScores to % the sum of itself and the next element, except for the last element % which stays the same bonusScores = userScores; end Code to call your function when you click Run
Computers and Technology
1 answer:
Nat2105 [25]3 years ago
3 0

Answer:

The program to this question can be given as:

Program:

#include<stdio.h>  //header file.

int main()

 //main function

{

   int SCORES_SIZE = 4;  //define variables.

   int bonusScores[]={10,20,30,40};  //define array.

   int i;

   printf("Values:");

 //message

   for (i = 0; i < SCORES_SIZE; ++i)  //loop for print values.

   {

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

   }

void CombineScores(int numberScore, int userScore) //function

{

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

  //loop for convert values

   {

       if (( bonusScores[i] <= bonusScores[i +1] ) || (bonusScores[i] < bonusScores [i+1]))  //check array elements

       {

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

 //add values

       }

       else

       {

           bonusScores[i] = bonusScores[i];

       }

   }

   printf("\nReturn values:");  //message

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

{

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

}

}

CombineScores(0,0); //calling

return 0;

}  

Output:

Values:10 20 30 40  

Return values:30 50 70 40  

Explanation:

In the above c++ programming code firstly we define the header file. Then we define the main function in this function we define variable that name is given in the question that is SCORES_SIZE, i. Variable i is used in the loop for a print array. Then we define and initialize an array. The array name is and elements are define in the question that is bonusScores[]={10,20,30,40}. Then we use the loop for print array elements.Then we define function that is CombineScores() in this we pass two parameter. Then we use the second time in this loop we check array elements and add the elements that are given in the question. In this function we print values and at the end we call function.

You might be interested in
What is stored in alpha after the following code executes?
Daniel [21]

Answer:

Option 3: alpha = {3, 2, 9, 6, 8}

Explanation:

Given an an array, <em>alpha,</em> with 5 integer elements.

What happen inside the for-loop is that

  1. The current index-j will be multiplied by 2 and then assigned as the value of the element of the array indexed by j.
  2. If the index-j is an odd number (j % 2 == 1),  the previous element of the array, alpha[j - 1] will be assigned with value of alpha[j] + j. For example, given the alpha[0] = 0. If j = 1, alpha[j - 1] = alpha [0] = alpha[1] + 1= 2 + 1 = 3
  3. In short, the elements with even index-j are simply equal with 2 * index-j. Whereas the elements with odd index-j will always equal to  alpha[j - 1] = alpha[j] + j  

3 0
4 years ago
Denelle, an accountant, needs to present her client Stephen with a page showing how his yearly retirement savings will be affect
mihalych1998 [28]

Answer:

Ok so the power of sussy is hard to find because you have to be sus which the impostor sus sussy then you sus more of the sus then you get the sus sus sus sus sus sus sus sus sus sus sus amogus.

Explanation:

4 0
3 years ago
What two things should you do before starting the design process
Charra [1.4K]

Answer: B and C

Explanation: Analyze the audience

                      Identify the problem

8 0
3 years ago
"The correct syntax for passing an array as an argument to a method when a method is called and an array is passed to it is: "
Monica [59]

Question:

"The correct syntax for passing an array as an argument to a method when a method is called and an array is passed to it is: "

A) a[0]..a[a.length]

B) a()

C) a

D) a[]  

Answer:

The correct answer is A.

An example is given in the attachment.

Cheers!

4 0
3 years ago
If ClassC is derived from ClassB which is derived from ClassA, this would be an example of ________.
finlep [7]

Answer:

Inheritance

Explanation:

8 0
3 years ago
Other questions:
  • A neologism is defined as:
    5·1 answer
  • A project team was researching the risks involved in setting up a computer system. They decide to go ahead with their plan, rega
    7·1 answer
  • Jeanne writes a song, and Raul wants to perform
    6·2 answers
  • In the context of the planning phase of the systems development life cycle (SDLC), which is an example of an internally identifi
    6·1 answer
  • What data unit is addressed based on the IP address of the recipient?
    8·1 answer
  • What are common names for some primary discrete components used on circuit boards?
    13·1 answer
  • Given a Scanner reference variable named input that has been associated with an input source consisting of a sequence of lines,
    13·1 answer
  • Love me love me say that u love me fool me fool me go on and fool me : ) answer the question thx
    6·2 answers
  • Name any five application or uses of smartphone and computer.<br>​
    8·1 answer
  • In java language I want the code
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!