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
Conceptos importantes de red de computadoras
Bumek [7]

Answer:

-Consiste en conectar varias redes de computadoras basadas en diferentes protocolos -Requiere la definición de un protocolo de interconexión común sobre los protocolos locales. -El Protocolo de Internet (IP) desempeña este papel, definiendo direcciones únicas para una red y una máquina host.

3 0
3 years ago
You can run a macro by:
oee [108]

Selecting the button assigned

Using the shortcut Keys assigned

Explanation:

By clicking the assigned button one can run a macro and we can assign a short cut key to macro which we created.

So, the two options we can use to run a macro.

7 0
3 years ago
Buying a new computer for which of these reasons is most likely a sound
Svetllana [295]

Answer:

b. you need it to do your homework

Explanation:

3 0
2 years ago
In command prompt, Whats a command that will list only .ini files in C:\Windows\System32 directory?
Ber [7]

Answer:

The dir command is a Command Prompt command that's used to display a list of the files and subfolders contained in a folder.

hope it helps

3 0
3 years ago
Read 2 more answers
The giant eniac stores how much size memory
swat32

if you mean the giant eniac stores how much memory, the answer would be that the original model had no storage but later a 100-word storage core was installed

3 0
3 years ago
Other questions:
  • Java languageThe cost to ship a package is a flat fee of 75 cents plus 25 cents per pound.1. Declare a constant named CENTS_PER_
    5·2 answers
  • when you create workplace documents, it is most important to ensure that they are clear, professional, and a. short. b. informal
    7·1 answer
  • Which information is necessary to determine an object's speed?
    13·1 answer
  • Whats the difference between copying a file to my desktop and creating a shortcut?
    8·1 answer
  • On the seventh day of the iteration, the team realizes that they will not complete 5 of the 13 stories. the product owner says s
    12·1 answer
  • With microprocessors, The integration of a whole _____ onto a single chip or on a few chips greatly reduced the cost of processi
    14·1 answer
  • 1)Which of the following statements about the print statement are TRUE? (Check all that apply)
    8·1 answer
  • Draw a flow chart that accepts mass and volume as input from the user. The flow chart should compute and display the density of
    8·1 answer
  • Write programs in python to display “Valid Voter”. (condition : age of person should be
    10·1 answer
  • _____ provides the best video resolution. *<br><br> VGA<br> HDMI<br> USB<br> DVI
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!