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 term describes the distinct number of colors a graphic contains? (1 point)?
laila [671]
Your answer would be "Hue".
4 0
3 years ago
What sequence is used to create a brochure document from a template?
GenaCL600 [577]

Answer:

computer is used to create a voucher document

6 0
2 years ago
Read 2 more answers
Robert and Anne, a married couple filing jointly, have an adjusted gross income of $68,676. They claim two exemptions, and can d
artcher [175]

Answer:

the answer is B

Explanation:

Just took the test

8 0
2 years ago
Read 2 more answers
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
2 years ago
Plz help
Rama09 [41]

Answer:

name

Explanation:

name =

is an assignment to the variable called 'name'.

5 0
2 years ago
Read 2 more answers
Other questions:
  • A manufacturer of machine tools creates a spreadsheet of tools and the cost for those. The spreadsheet has four fields: name of
    13·1 answer
  • Type the correct answer in the box. Spell all words correctly. Joseph is a digital media developer and has years of work experie
    15·1 answer
  • The length property of the String object returns
    15·1 answer
  • You're setting up some VMs to test an application you're considering making available to employees of the small company you work
    11·1 answer
  • How does cryptocurrency exchange software works?
    14·1 answer
  • Which one is not the part of motherboard ?<br>O Registers<br>O<br>Bus<br>O<br>Port<br>O<br>none​
    14·1 answer
  • What can happen if you do not follow the directions of medicine or the directions from the doctor? (Give 4 examples)​
    15·1 answer
  • Kelly wants to change the text in a cell so that it is centered instead of left-aligned, where should she look to make this
    8·1 answer
  • PLEASE HELP! :)
    14·1 answer
  • What is assembler? What is Compiler?What is interpreter?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!