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
Given an list of N integers, Insertion Sort will, for each element in the list starting from the second element: Compare the ele
Elena L [17]

Answer:

def insSort(arr):

ct=0;

for i in range(1, len(arr)):

key = arr[i]

j = i-1

while j >=0 and key < arr[j] :

arr[j+1] = arr[j]

j -= 1

ct=ct+1;

arr[j+1] = key

return arr,ct;

print(insSort([2,1]))

Output of the program is also attached.

8 0
3 years ago
A(n) __________ is a common list operation used in programming. Its purpose is to iterate through a list of items, one item at a
34kurt
Linear search

You implement this algorithm by iterating over each item, and checking if the item matches what you are searching for.

It is linear because it takes a linear amount of time to search for an item.
5 0
2 years ago
After merging two arrays is complete you need to
VikaD [51]

Answer: C) copy the merged array back to the original array

Explanation:

 After performing merging of two array then, copy the merge array back to its original array. Merging of two array is done by the process of merge sort. Merging of two array is the similar process of concatenate the two array into the single object.

It basically works on the principle of divide and conquer algorithm. It divide the input value into the two half and then, sorted the accordingly. Then after completion of merging the two array it copy into the original array.

5 0
3 years ago
Examination of Internet records in order to reveal the identity of an anonymous poster is defined as
Sergeu [11.5K]

Answer: Doxing

Explanation: Doxing which is also referred as doxxing is defined as the revealing or publishing of the private records or information to the public.It is considered as the illegal practice which is base on the the internet service.The publicizing of the private data or confidential information is punishable offence.

Other options are incorrect because filtering is the elimination of the not required content, spamming is the activity of sending undesired bulk messages and hacking is the attacking of the system using false means to corrupt and steal data.Thus the correct option is doxing.

6 0
3 years ago
With the sheets grouped, apply Underline to cell B5 and Double Underline to cell B6. Ungroup the worksheets. Note, use the Forma
Orlov [11]

Answer:

Check Explanation.

Explanation:

Task: (1). Apply Underline to cell B5 and Double Underline to cell B6.

(2). Ungroup the worksheets.

(3).use the Format Cells dialog box to ensure that the Underline styles Single and Double are applied, rather than Single Accounting or Double Accounting.

Steps to follow;

Step one: On the Excel document that you are working on, make sure you highlight from B6 cell to F6 cell.

Step two: Then, press CTRL+SHIFT+F.

Step three: from action in step two above, the "format cells dailogue box" will come up, click underline > (underline type) dropdown list > ok.

Step four: next, highlight from B7 to F7.

Step five: press CTRL+SHIFT+F. As in step two above.

Step Six: do the same thing as in Step three above.

Please note that to apply the SINGLE UNDERLINE, you need to type the data in the cell for cells of B6 to F6 ONLY.

Also, for DOUBLE UNDERLINE for B7 to F7; just type the data in the cell and it will apply.

4 0
3 years ago
Other questions:
  • What is computer engineering?
    11·1 answer
  • A user is experiencing slow performance with their computer. A technician suspects the computer has a virus and runs antivirus s
    12·1 answer
  • For which of the following careers is technology’s connectivity factor most important?
    13·2 answers
  • What is a central location that houses Joint Information System (JIS) operations and where public information staff perform publ
    6·1 answer
  • Which of the following is a technique used by hackers to identify unsecured wireless network locations to other hackers?A. Blues
    10·1 answer
  • The design of a blog refers to:
    10·1 answer
  • IF YOU COULD CREATE A SOCIAL NETWORK:, what would it be like? What would make it so special about the others? (If you want you c
    9·1 answer
  • The complete process for learning through repetition is to read, write, say, rest and revisit the information. Please select the
    12·2 answers
  • Read the introduction (paragraphs 1-3].
    7·1 answer
  • What Microsoft feature enables you to represent text as colorful visuals
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!