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
patriot [66]
2 years ago
15

Create a function called makePositive that accepts a single argument: an integer array. The function should walk through the arr

ay and change any negative numbers to positive. You can assume that the array passed to the function will have a 0 at the end of the array. In other words, you do not know the size of the array; you instead know that a certain condition will be true at the end of the array.
Computers and Technology
1 answer:
coldgirl [10]2 years ago
8 0

Answer:

This solution is implemented in C++

void makePositive(int arr[]){

   int i =0;

   while(arr[i]!=0){

       if(arr[i]<0){

           arr[i] = abs(arr[i]);

       }

       i++;

   }

   i = 0;

   while(arr[i]!=0){

    cout<<arr[i]<<" ";

    i++;

}  

}

Explanation:

This defines the function makePositive

void makePositive(int arr[]){

This declares and initializes i to 0

   int i =0;

The following iteration is repeated until the last element in the array

   while(arr[i]!=0){

This checks if current array element is negative

       if(arr[i]<0){

If yes, it changes it to positive

           arr[i] = abs(arr[i]);

       }

The next element is then selected

       i++;

   }

This sets i to 0

   i = 0;

The following iteration prints the updated content of the array

<em>    while(arr[i]!=0){ </em>

<em>     cout<<arr[i]<<" "; </em>

<em>     i++; </em>

<em> }   </em>

}

See attachment for full program which includes the main

Download cpp
You might be interested in
Which best describes the benefits of renting a home?
WARRIOR [948]
The benefits are that you don't have to worry if something breaks from like a water leake or a storm and get destroyed the home owners have to pay
7 0
3 years ago
Read 2 more answers
NFPA 780, Standard for the Installation of Lightning Protection Systems provides information on the installation of _____ for li
Andrews [41]

Answer:

a and b. 250.4(A)(1) Note

Explanation:

4 0
2 years ago
Which design principle indicates the degree of darkness or lightness of a color in a design? _________is the degree of darkness
Svetlanka [38]
It's value, I believe so atleast.
8 0
3 years ago
Damage to which portion of the limbic system results in loss of memory of recent events and difficulty committing anything new t
Vera_Pavlovna [14]

Answer:

Hippocampus.

Explanation:

There are two parts of the limbic system. They are the frontal part which is the amygdala and the posterior part which is the hippocampus.

The hippocampus is an extension of the temporal part  of the cerebral cortex which is a plastic-like structure that can be easily damaged by stimuli. It is packed with densed neurons and forms an S-shape at the extension of the temporal part.

It is responsible for learning and memory and damage to it can result to memory loss of recently learnt information.

8 0
2 years ago
BIOS has two jobs. One is to boot up, or start, the computer. What is the other? Maintain the computer’s software firewall. Ensu
Levart [38]

Answer:

Provide the basic interface for the hardware.

Explanation:

3 0
3 years ago
Other questions:
  • What is one word for inventiveness uncertainty and futuristic
    5·1 answer
  • The ____ operation is used to add an element onto the stack.
    15·1 answer
  • Which major milestones started off the progression that led to the modern computers we play games on now? What do you think affe
    14·1 answer
  • When reading words using a Scanner object's next method, _________. a. any characters at the beginning of the input that are con
    5·1 answer
  • Which These operating systems use a graphical user interface?
    6·1 answer
  • 12.
    10·1 answer
  • While using a web-based order form, an attacker enters an unusually large value in the Quantity field. The value he or she enter
    15·1 answer
  • Does analogue conversation take place in source as transmitter?
    5·2 answers
  • I NEED HELP, DO ASAP <br> Why do you have to adjust toys for different ages?
    11·2 answers
  • Travelers should keep their profile information up-to-date. which is not an option for a traveler to update their own profile in
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!