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]
3 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]3 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
Client/server awareness. Visit three local stores in your neighborhood or mall and notice the information technology in the stor
Kaylis [27]

local stores in neighborhood do not have computerized cash registers but they may have cameras if they are in a bad neighborhood. inventory is controlled by checking the shelves.


the Qs about computers, servers and clients are for national chain stores. they use clients at each store which are connected to the central servers at HQ. employees need special training as the system is complicated. the whole system is maintained by their IT department.


7 0
3 years ago
Read 2 more answers
How do we explain the difference between fake news and facts​
Natalija [7]

Answer: it depends if the news is on the news and someone rights an article about it and says some mislead details that's how u know its fake  

Explanation:

3 0
3 years ago
Altering grade records within a computer system is called
Cloud [144]
Altering grade records within a computer system is called forgery. The correct option among all the options given in the question is option "a". Any kind of altering using the computer without the consent of the proper authorities amounts to forgery. Forgery is a crime and a person can be jailed for such a serious offense.
4 0
3 years ago
Read 2 more answers
The base class Pet has private fields petName, and petAge. The derived class Dog extends the Pet class and includes a private fi
Lapatulllka [165]

Answer:

Hello attached is the Java program written to solve the problem

The Pet.java and Dog.java files are unaltered

Explanation:

The input and output  codes are attached as well i.e the second image is the input while the third image is the output code

5 0
3 years ago
Write a program that asks the user to enter a number of seconds and then printsthe same amount of time in days, hours, minutes,
MariettaO [177]

Answer:3363 seconds

Explanation:3363 is equivalent to 0days 1 hour, 1 min, and 7 sec

8 0
3 years ago
Other questions:
  • 2-Write test programs in java to determine the scope of a variable declared in a for statement. Specifically, the code must dete
    7·1 answer
  • Declare a character variable letterStart. Write a statement to read a letter from the user into letterStart, followed by stateme
    12·1 answer
  • A slideshow that accompanies an oral report is known as what?
    6·1 answer
  • 3. What term refers to the physical locations of elements in relation to each other?
    10·2 answers
  • Suppose that class OrderList has a private attribute double cost[100] which hold the cost of all ordered items, and a private at
    14·1 answer
  • Kara has been asked to create an employment application form for her company. Which of the following items can she use to make s
    10·1 answer
  • True/False/Unknown. For the interpretation of function calls, we assign the formal parametersto the valuations of the actual arg
    11·1 answer
  • 4. In paragraph 7, what is the meaning of the phrase "not
    13·1 answer
  • Who is your favorite person from squid game?
    13·2 answers
  • Effective online learning method for students
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!