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
Write a program that produces the following output (where the user may enter any positive integer under 10):______
Mekhanik [1.2K]

Answer:

// The Scanner class is imported to allow the program receive user input

import java.util.Scanner;

// The class is defined called Solution

public class Solution {

   // The main method is defined which begin program execution

   public static void main(String args[]) {

     // Scanner object 'scan' which receive user input from the keyboard

     Scanner scan = new Scanner(System.in);

     // the userInput variable is initially set to 1 (true) to allow the program continue prompting the user for input

     int userInput = 1;

     // while loop which continue execution as long as the userInput is greater than 0 and less than 10

     while (userInput > 0 && userInput < 10){

         // Prompts is displayed to the user to enter number below 10

         System.out.println("Enter a positive integer under 10:__________");

         // the next input is assigned to userInput

         userInput = scan.nextInt();

     }      

   }

}

Explanation:

The above code continue prompting the user to input an integer as long as the input is greater than 0 and less than 10.

3 0
3 years ago
Match the tool to the task it helps to accomplish.
olga2289 [7]

Answer:

Translate ➡️ allows the user to change words from one language to another

Smart Lookup➡️allows user to find the definition of a word or a phrase.

Thesaurus ➡️ allows the user to find the synonyms and antonyms of a word.

Explanation:

I have been able to match each took to the tasks that they perform.

In Translate, users can easily change words into a different language. That means that words in English can be translated into French, Spanish, etc., and vice versa.

In Smart Lookup, users can actually find definitions of words or phrases. Smart Lookup can be found in Microsoft Word Office.

The Thesaurus is used to find the synonyms and antonyms of words.

These tools make learning very easy and enjoyable.

8 0
3 years ago
Alice has 1/5 as many miniature cars as Sylvester has slyvester has 35 miniature cats how many miniature cars dose Alice have
garik1379 [7]
Alice has 7 miniature cars
5 0
3 years ago
An eco-friendly home-building company has asked you to create their logo. Which of the following color schemes would work best t
galben [10]
I'm not sure what the letters represent concerned with the colour scheme, however the most common colour in nature is green.

The least common colour in nature is blue.

Hope this helps! :)
7 0
3 years ago
Nancy finds it difficult to locate emails in her Inbox. What action should she take to locate a particular type of email instant
exis [7]
Your answer would be A. Hope this helps!;)

4 0
3 years ago
Read 2 more answers
Other questions:
  • Consider the unsigned decimal number 35. What is the value in hexadecimal?<br><br> 1. 3510 = ____ 16
    13·1 answer
  • . The toasting cycle of an automatic toaster is started by A. pushing the bread rack down. B. pushing the start button. C. turni
    14·2 answers
  • To celebrate earth day, the employees of a company plan to reduce their carbon footprint in the workplace. Identify the changes
    5·2 answers
  • What can a person do to help increase their credit score?
    12·1 answer
  • One of the disadvantages of Photoshop Express is that it does not have a Black and White effect. True False
    13·1 answer
  • _____ involves storing data and running applications outside the company’s firewall. answer grid computing parallel computing cl
    11·1 answer
  • A programmer has an idea to use just one language for the content, structure, and style of web pages. What might be a problem wi
    11·1 answer
  • PLEASE HELP!! WILL MARK BRAINLIEST!!
    15·1 answer
  • Learning Management Systems (LMS) allow students to interact with each other, but NOT their teachers.
    10·2 answers
  • 1. What is hydrolics?​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!