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
Which of the following solutions enables simultaneous digital transmission of voice, video, data, and other network services ove
Annette [7]

Answer:

3. ISDN

Explanation:

ISDN ( Integrated Services Digital Network  ) -

It is the used for the simultaneous digital transmission of network service , data , video and voice , instead of the old circuits of the public switched telephone network ( PSTN ) , is referred to as ISDN .

The characteristic feature of ISDN is that it integrates the data and speech on the same lines , which is not possible in PSTN .

Hence, from the given information of the question,

The correct option is ISDN .

8 0
3 years ago
What does it mean when someone silences notifications?.
grandymaker [24]

Answer:

Silencing notifications does not alert someone when the notification comes in. It is silent. These settings were invented to help avoid distractions. The notifications still come in just quietly without an alert and can be checked at any time. Lots of people silence notifcations at night, while sleeping, while studying, etc.

Explanation:

4 0
2 years ago
What type of encryption is currently used to secure wpa2?
MaRussiya [10]
AES (Advanced Encryption standard) is currently used to secure wpa2.
3 0
3 years ago
What does using indirect quotations allow a writer to do?
Marrrta [24]
Indirect quotations can add information that strengthens your content in many of the same ways as direct quotations so. Essentially, indirect quotes carry the meaning of a speaker or writer's original words without using the exact words.
7 0
3 years ago
Read 2 more answers
The best way to safeguard your document is to save it
givi [52]
The answer is C every few minutes
8 0
3 years ago
Other questions:
  • You will use the _____
    15·2 answers
  • Which process is used to protect transmitted data in a vpn?
    12·1 answer
  • Technologies that allow for instant worldwide communication include satellite and computer systems. mobile phones and internet a
    8·2 answers
  • What is the final value for X ?<br><br> x= 1<br><br> x=13<br><br> x= x+3<br><br> x=0
    9·1 answer
  • When Google created its China-based search engine www..cn, they did not foresee eventually abandoning it because of censorship i
    12·1 answer
  • Which is a connectionless protocol in the transport layer? What are the small chunks of data called?
    12·2 answers
  • What is the grade, as a percentage with two digits after the decimal point, obtained when you graded this 101-question multiple-
    13·1 answer
  • How do i copy a canvas course from old class to new course.
    12·1 answer
  • You are configuring NIC Teaming on a Windows Server system using two physical network adapters. You want to aggregate the bandwi
    10·1 answer
  • A computer professional's job involves analyzing computer systems for
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!