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
Makovka662 [10]
3 years ago
7

Modify an array's elements using other elements Write a for loop that sets each array element in bonusScores to the sum of itsel

f and the next element, except for the last element which stays the same. Be careful not to index beyond the last element. Ex: If bonusScores = [10, 20, 30, 40], then after the 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.
Computers and Technology
1 answer:
Igoryamba3 years ago
5 0

Answer:

The program to this question can be given as:

Program:

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

int main()

//main function

{

  int i;  //define variables.

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

   printf("Values:");  //message

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

{

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

}

for (i = 0; i <4; 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 < 4; ++i) //loop for print values

  {

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

  }

  printf("\n");

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 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. We use the second time in this loop we check array elements by using the condition statements in if block we add the elements and in else we print last value. At the last, we use the loop for print array.

You might be interested in
Suppose we perform a sequence of n operations on a data structure such that if some condition C(k) holds then the kth operation
GrogVix [38]

Answer:

stay home, stay safe, dont get corona virus

Explanation:

7 0
3 years ago
What acts as a platform on which application software runs?
Readme [11.4K]
A computing platform
5 0
3 years ago
Sample outputs with inputs 9 5 2 -1 in python.
Nezavi [6.7K]
Sorry phsnjajajajqjkakw
7 0
3 years ago
hãy lựa chọn một doanh nghiệp kinh doanh theo loại hình siêu thị việt nam em hãy tìm hiểu doanh nghiệp và thực hiện theo yêu cầu
Anastasy [175]

Quy trình kinh doanh, phương pháp kinh doanh hoặc chức năng kinh doanh là một tập hợp các hoạt động hoặc nhiệm vụ có liên quan, có cấu trúc bởi con người hoặc thiết bị, trong đó một trình tự cụ thể tạo ra một dịch vụ hoặc sản phẩm (phục vụ một mục tiêu kinh doanh cụ thể) cho một khách hàng cụ thể.

4 0
3 years ago
Terminal emulation, especially the unprotected ____________________ protocol, should be blocked from any access to all internal
Ivahew [28]

Answer:

telnet

Explanation:

<h2><u>Fill in the blanks </u></h2>

Terminal emulation, especially the unprotected <u>telnet </u>protocol, should be blocked from any access to all internal servers from the public network.

4 0
2 years ago
Other questions:
  • Is a type of bullying that takes place when a person intentionally posts negative information about another that is not true
    8·1 answer
  • Modify the program so the output is: Annual pay is 40000 Note: Whitespace (blank spaces / blank lines) matters; make sure your w
    9·1 answer
  • Wide area networks are defined by their ability to
    14·2 answers
  • Write a program to generate personalized junk mail. The program takes input both from an input file and from the keyboard.The in
    14·1 answer
  • Which small-group format would be most appropriate for the following situation? A large sporting event is coming to town. Key me
    14·2 answers
  • How would improving the nutritional health of an entire community impact the overall physical, emotional, and financial health o
    14·1 answer
  • The set of rules for how computers talk to one another
    6·1 answer
  • What is the purpose of a career portfolio?
    6·1 answer
  • When creating a shape in Word, what are some available options? Check all that apply. adding text to the shape changing the size
    6·1 answer
  • Explain Http and Ftp​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!