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
Numdu
gizmo_the_mogwai [7]
The question is unclear /unfinished please send again.
4 0
3 years ago
Need Help!
Aleksandr-060686 [28]

Answer:

A and C are the only <u>legal</u> but unethical options

4 0
3 years ago
Which type of network topology is the most common and easiest to use?
Airida [17]
<span>A network layout or topology that is the most common, the most simple and easiest to use out of the four network topologies is the Bus topology, one cable is used for installation so it is also the cheapest network type.</span>
5 0
3 years ago
Which are guidlines for using themes? Check all that apply
Andreyy89

Answer: A. Using different cell styles can help you differentiate different types of data.

B. Fonts should be easily readable and of appropriate size.

D. Be consistent with themes across worksheets and workbooks.

Explanation:

A theme refers to the preset package that contains functionality details and graphical appearance.

The guidelines for using themes include:

• Using different cell styles can help you differentiate different types of data.

• Fonts should be easily readable and of appropriate size.

• Be consistent with themes across worksheets and workbooks.

Therefore, the correct options are A, B and D.

7 0
3 years ago
When you connect a new hardware device to your computer, the operating system uses a feature called _______ so you can use the n
dalvyx [7]

Answer: Plug and play

Explanation:

Adding a new hardware to the computer activate the plug and play module of the operating system which installs the hardware device into the computer and enables us to use it immediately.

6 0
2 years ago
Other questions:
  • Which translator program reads small portions of a program at a time, translating them into machine instructions which are then
    12·1 answer
  • Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards
    7·1 answer
  • (It science question)
    9·1 answer
  • Write the definition of a function named printstarbucks that receives a non-negative integer n and prints a line consisting of n
    6·1 answer
  • Which of the following best defines Monte Carlo simulation?a. It is a tool for building statistical models that characterize rel
    11·1 answer
  • What type of error results from an error in the formatting of the program code?
    13·1 answer
  • Data is best described as
    10·2 answers
  • A human interest story is an example of hard news.<br> O True<br> O False HEL
    15·1 answer
  • When you open a program, the hard drive
    7·1 answer
  • How does the dns solve the problem of translating domain names like example.com into ip addresses?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!