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
Children may be placed in restraining devices such as high chairs, swings or bouncy seats
Ratling [72]
Yes in my opinion. People will say no but there is no right answer
8 0
3 years ago
Write a class of complex numbers consisting of:
Gnom [1K]

Answer:

hi sorry for not knowing the answer

but please follow have a great day,night, or afternoon

3 0
3 years ago
The processing of data in a computer involves the interplay between its various hardware components.
Ronch [10]

True.

Data processing involves the conversion of raw data and the flow of data through the Central Processing Unit and Memory to output devices. Each CPU in a computer contains two primary elements: the Arithmetic Logic Unit (ALU) and the control unit. The Arithmetic Logic Unit performs complex mathematical calculations and logical comparisons. On the other hand, the control unit accesses computer instructions, decodes them, and controls the flow of data in and out of the Memory, ALU, primary and secondary storage, and various other output devices.  


8 0
3 years ago
Write a while loop that prints 1 to user_num. Sample output for the given program: 1 2 3 4
Scorpion4ik [409]
Given 1234
i=1
user num=4#assume positive
while (user-num>=i);
print(i)
i+=1
#include <iostream>
using namespace std;
int main()
{int userNum=0;
int i=0;
userNum=4; ##assume positive
i=1;
while (i <=userNum){
cout<<i>>" ";
i=i+1;
cout <<endl;
return0;
}
6 0
3 years ago
Read 2 more answers
When referring to computers, what does CRT stand for?
vampirchik [111]

CRT stands for <u>"Cathode Ray Tube".</u>

CRT are the many tiny green, blue, and red beams that shine to create an image on the computer screen.

8 0
3 years ago
Other questions:
  • 4. Scientists are not concerned with the human impact on the environment. True or False?
    6·2 answers
  • Enterprise application integration (eai) software enables users to model the business processes and interactions that should occ
    8·1 answer
  • Database administrators must make sure that ________ and ________ techniques and procedures are operating to protect the databas
    6·1 answer
  • While inspecting an element in the DOM on my website using the Chrome Devtools I accidentally deleted the DIV that had all my au
    8·1 answer
  • Anyone who uses Edmentum Plato homeschool can anyone please help me my biology is not loading and it says flash is not available
    7·2 answers
  • Design the logic for a program that allows a usher to continuously enter numbers until the usher enters 0. Display the sum of th
    9·1 answer
  • What is an Operating System ??
    7·1 answer
  • Consider the following code.
    7·2 answers
  • How many bits would be needed to count all of the students in class today? There are 40 students.
    10·1 answer
  • What is a reason for users and businesses to adopt 5G networks?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!