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
Natasha_Volkova [10]
3 years ago
11

Given an array arr, of type int, along with two int variables i and j, write some code that swaps the values of arr[i] and arr[j

]. declare any additional variables as necessary.
Computers and Technology
1 answer:
Inessa05 [86]3 years ago
3 0

You'll need a helper variable for this, so depending on your programming language, the solution becomes:

int helper;

helper = arr[i];

arr[i] = arr[j];

arr[j] = helper;

You might be interested in
Print person1's kids, call the incNumKids() method, and print again, outputting text as below. End each line with a newline.
Brilliant_brown [7]

Answer:

Explanation:

The following code was written in Java and modifies the code so that for the given input such as 3 it outputs the exact information shown in the sample output.

import java.util.Scanner;

class CallPersonInfo {

   public static void main(String [] args) {

       Scanner scnr = new Scanner(System.in);

       PersonInfo person1 = new PersonInfo();

       int personsKid;

       System.out.println("How many kids do you have:");

       personsKid = scnr.nextInt();

       person1.setNumKids(personsKid);

       /* Your solution goes here */

       System.out.println("Kids: " + person1.getNumKids());

       person1.incNumKids();

       System.out.println("New Baby, kids now: " + person1.getNumKids());

   }

}

class PersonInfo {

   private int numKids;

   public void setNumKids(int setPersonsKids) {

       numKids = setPersonsKids;

   }

   public void incNumKids() {

       numKids = numKids + 1;

   }

   public int getNumKids() {

       return numKids;

   }

}

4 0
3 years ago
Which is an example of a variable name written in camelcase?
stiv31 [10]

Answer: songName

-DoggyMan5

4 0
3 years ago
Read 2 more answers
Go follow me plz i would appreciate it
aleksandr82 [10.1K]
Hejdjxuxudjjdjdbdbdbd
6 0
3 years ago
Read 2 more answers
Definition of firewall
miv72 [106K]
A partition made of fireproof material to prevent the spread of a fire from one part of a building or ship to another or to isolate an engine compartment, as on a plane, automobile, etc.
3 0
2 years ago
Read 2 more answers
Public speaking and composition writing are very similar forms of communication. True False
Harman [31]

True facts right there

4 0
4 years ago
Other questions:
  • Write a method void Print(int LastNumber, int numbersPerLine) that receives two integers
    15·1 answer
  • Samantha received a gaming session as a gift. She would like to have it communicate with her sister Jennifer’s gaming system so
    15·1 answer
  • Are the ways data is represented and transmitted with computers laws of nature or laws of man?
    10·1 answer
  • Writing a program in a language such as c or java is known as _____ the program.
    10·1 answer
  • ​______________________ is a general security term that includes computer​ viruses, worms, and trojan horses.
    13·1 answer
  • The idea behind ____ is that the peripheral can simply be plugged in and turned on, and that the computer should dynamically rec
    10·1 answer
  • Which is a reason why an organization might get rid of its entire information processing unit?
    10·1 answer
  • Which entity might hire a Computer Systems Analyst to help it catch criminals?
    12·2 answers
  • Please help i have 15 mins
    5·1 answer
  • WILL GIVE BRAINLIST Which statements accurately describe electronic tools? Check all that apply. Electronic tools collect large
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!