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
zhannawk [14.2K]
3 years ago
14

Write a loop that subtracts 1 from each element in lowerScores. If the element was already 0 or negative, assign 0 to the elemen

t. Ex: lowerScores = {5, 0, 2, -3} becomes {4, 0, 1, 0}.Sample program:#include using namespace std;int main() { const int SCORES_SIZE = 4; vector lowerScores(SCORES_SIZE); int i = 0; lowerScores.at(0) = 5; lowerScores.at(1) = 0; lowerScores.at(2) = 2; lowerScores.at(3) = -3; for (i = 0; i < SCORES_SIZE; ++i) { cout << lowerScores.at(i) << " "; } cout << endl; return 0;}Below, do not type an entire program. Only type the portion indicated by the above instructions (and if a sample program is shown above, only type the portion.)
Computers and Technology
1 answer:
Verdich [7]3 years ago
8 0

Answer:

Replace <STUDENT CODE> with

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

       if(lowerScores.at(i)<=0){

           lowerScores.at(i) = 0;

       }

       else{

           lowerScores.at(i) = lowerScores.at(i) - 1;

       }  

   }

Explanation:

To do this, we simply iterate through the vector.

For each item in the vector, we run a check if it is less than 1 (i.e. 0 or negative).

If yes, the vector item is set to 0

If otherwise, 1 is subtracted from that vector item

This line iterates through the vector

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

This checks if vector item is less than 1

       if(lowerScores.at(i)<1){

If yes, the vector item is set to 0

           lowerScores.at(i) = 0;

       }

       else{

If otherwise, 1 is subtracted from the vector item

           lowerScores.at(i) = lowerScores.at(i) - 1;

       }  

   }

Also, include the following at the beginning of the program:

<em>#include <vector></em>

You might be interested in
How Oracle 12c advances the security discussion?
krok68 [10]

Answer: The oracle 12 c advances are given below.

Explanation:

The oracle 12 c provides the ability to tag the data with the label of data. It provides the classification to the data. This allows to check which data is sensitive and also allows the combination of sensitive data to be combined with the same table as the bigger data without compromising the security of the database.

8 0
4 years ago
The ________ stage of a project involves such activities as forming a team, allocating resources, preparing project documentatio
marysya [2.9K]

Answer:

b. organizing

Explanation:

In the organising stage of a program life cycle involves such activities as forming a team, allocating resources, preparing project documentation, and ensuring good communication.

The organising stage can also comprise of the following activities;

1) To properly Organise and prepare a project.

2) Typically it involves conducting research and making use of its results to design a prototype or service for testing.

3) Here there is also nees to prepare and implement a schedule

4) Identifying the targets within the project

5) Distributing the tasks and resources to the team

6) Adjusting the members of the project team as needed

6 0
4 years ago
What are some useful applications of video games?
vekshin1

Answer:

Steam, Origin, Uplay and epic games

Explanation:

8 0
3 years ago
Why is self-esteem important in self-representation
german
Hello! Self-esteem is important in self-representation, because the way you feel yourself can affect how you represent yourself as well. For example, if you have low self-esteem, you may present yourself as sad and shameful. However, if you have high self-esteem, you present confidence and happiness to other people.
3 0
4 years ago
Port explorers ​are tools used by both attackers and defenders to identify (or fingerprint) the computers that are active on a
Evgesh-ka [11]

Answer:

b) False.

Explanation:

Port explorers ​are tools used by both attackers and defenders to identify (or fingerprint) the computers that are active on a network, as well as the ports and services active on those computers, the functions and roles the machines are fulfilling, anAn IDPS can be configured to dial a phone number and produce an alphanumeric page or other type of signal or message., is a FALSE statement.

5 0
3 years ago
Other questions:
  • Which statement below correctly differentiates between frames and bits? Frames have more information in them than bits. Frames a
    10·2 answers
  • 1. What should you do if your computer is shared by your entire family and you install a plugin that saves user names and passwo
    5·2 answers
  • Can using interior light help improve a drivers visibility at night
    9·1 answer
  • Two types of business communications enhanced by desktop publishing are
    7·2 answers
  • Why do generated backup scripts usually include backticks around names such as database names and column names?
    5·1 answer
  • What statement best describes the Microsoft Windows operating system?
    13·2 answers
  • An ordinary office environment needs computers that have multiple user account settings where each user is allocated private dat
    13·1 answer
  • String member function compare compares two strings (or substrings) and returns 0 if:
    5·1 answer
  • What is the purpose of this parallelogram shape in a flowchart?
    15·1 answer
  • This code --&gt; plt.plot(x,y) is used to draw :
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!