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

Write a loop that sets each vector element to the sum of itself and the next element, except for the last element which stays th

e same. Be careful not to index beyond the last element. Ex:Initial scores: 10, 20, 30, 40Scores after the loop: 30, 50, 70, 40The 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 program:#include #include using namespace std;int main() { const int SCORES_SIZE = 4; vector bonusScores(SCORES_SIZE); int i = 0; bonusScores.at(0) = 10; bonusScores.at(1) = 20; bonusScores.at(2) = 30; bonusScores.at(3) = 40; for (i = 0; i < SCORES_SIZE; ++i) { cout << bonusScores.at(i) << " "; } cout << endl; return 0;}
Computers and Technology
1 answer:
Gekata [30.6K]3 years ago
6 0

Answer:

Add the following lines of code to the already existing code segment

<em>for (i = 0; i < SCORES_SIZE-1; ++i) { </em>

<em>        bonusScores.at(i) = bonusScores.at(i) + bonusScores.at(i+1);</em>

<em>  }</em>

Explanation:

To do the task in the question, we have to iterate through the vector from the first element i.e. element at index 0 to the second to the last element; i.e. element at last index - 1

We then add each element in this iteration with the next.

This iterates through the vector from 0 to SCORES_SIZE - 1

<em>for (i = 0; i < SCORES_SIZE-1; ++i) { </em>

<em>This adds each vector element with the next</em>

<em>        bonusScores.at(i) = bonusScores.at(i) + bonusScores.at(i+1);</em>

<em>  }</em>

The above should be added before

<em>for (i = 0; i < SCORES_SIZE; ++i) { </em>

<em>        cout << bonusScores.at(i) << " "; </em>

<em>}</em>

<em />

<em>Also, I've made other modifications to the program.</em>

  • <em>Proper import of header files</em>
  • <em>Proper declaration of vector bonusScores</em>

<em />

<em>See attachment for complete source code</em>

Download cpp
You might be interested in
Write a function that receives a StaticArray where the elements are already in sorted order, and returns a new StaticArray with
Allisa [31]

The code that remove duplicate is as follows:

def remove_duplicate(mylist):

    mylist = list(dict.fromkeys(mylist))

    return mylist

print(remove_duplicate([1, 1, 2, 3, 3, 5, 6, 7]))

<h3>Code explanation</h3>

The code is written in python.

  • we defined a function named "remove_duplicate" and it accept the parameter "mylist".
  • The variable "mylist" is used to store the new value after the duplicate vallues has been removed.
  • Then, wed returned mylist.
  • Finally, we call the function with the print statement . The function takes the required parameter.

learn more on python here: brainly.com/question/21126936

7 0
2 years ago
"You have an interface on a router with the IP address of 192.168.192.10/29. Including the router interface, how many hosts can
SSSSS [86.1K]

Answer:

6 hosts can have IP addresses on the LAN attached to the router interface

Explanation:

Given IP address

=> 192.168.192.10/29

It has a subnet mask of /29 which means it has 3 host bits. This is calculated by subtracting 29 from 32(number of bits in an IPV4)

Since there are 3 host bits,  the total number of possible addresses is given by

=> 2^{3} = 8 possible addresses.

Out of these 8 possible addresses, the first address will be the subnet id and the last address will be the broadcast address.

Therefore, there are only 6 addresses available for the hosts.

<em>Hope this helps!</em>

5 0
3 years ago
What process identifies and grants access to a user who is trying to access a system? A. Credibility
xeze [42]

Answer:

Option C is the correct answer for the above question

Explanation:

Authentication is used to grant a person to use the system so that no other person can hack the data of the system. It is done by some unique id which is provided to the user of that system. When any person wants to use the system he needs to use that a unique id and sometimes password and some other information to use the system.

The above question asked about the process through which the user of the system grants access to use the system only. So the process is Authentication. hence Option C is correct because it states about the process Authentication while the other is not because--

  • Option a states Credibility which is not the process to enter the system.
  • Option b states Authorization which is used if the system gives access to the user, not the user can take on its own.
  • Option d states Honesty which is not the process to enter the system.
8 0
3 years ago
20
denis-greek [22]

Answer:

true

Explanation:

because my 8 ball said so

6 0
3 years ago
Our new catalog contains an eclectic collection of items
Cloud [144]

Answer: .

Explanation: .

7 0
3 years ago
Other questions:
  • Who would be a tippee for purposes of insider trading? a. a janitor who gathers information by reading files on corporate counse
    6·1 answer
  • Consider the following code example:
    9·1 answer
  • I need this ASAP anyone pleas help me i have to do this by tonight
    10·1 answer
  • Digital Subscriber Line (DSL) is a way for traditional telephone companies to provide Internet access a way for traditional cabl
    10·2 answers
  • Playstation 4 how to change mtu settings
    12·1 answer
  • Windows, Apple’s Mac OS, and Unix/Linux are just some of the most common what?
    7·2 answers
  • Which type of microphone uses two metal plates?
    7·1 answer
  • Write an HTML document which contains two text fields, a button, and a div. The first text field should be labeled “Temperature”
    10·1 answer
  • What is the best data structure to solve the following problem? a) A list needs to be built dynamically. b) Data must be easy to
    11·1 answer
  • Write pseudo code that performs the following: Ask a user to enter a number. If the
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!