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
horrorfan [7]
3 years ago
12

Suppose that a is a one-dimensional array of ints with a length of at least 2. Which of the following code fragments successfull

y exchange(s) the values of the first two elements of a?I a[ 0 ] = a[ 1 ];a[ 1 ] = a[ 0 ];II int t = a[ 0 ];a[ 0 ] = a[ 1 ];a[ 1 ] = t;III a[ 0 ] = a[ 0 ] - a[ 1 ];a[ 1 ] = a[ 0 ] + a[ 1 ];a[ 0 ] = a[ 1 ] - a[ 0 ];A) I onlyB) II onlyC) III onlyD) I and II onlyE) II and III only
Mathematics
1 answer:
elixir [45]3 years ago
6 0

Answer:

E)II and III only

Step-by-step explanation:

This can be seen with examples. Say a[0]=1 and and a[1]=2.

for I , the first line of code would be:

a[0]=a[1];

thus, we would get a new value for a[0]=2.

The second line of code

a[1]=a[0]; uses the new value of a[0], so we would get a[1]=2.

The end result is a[0]=2, and a[1]=2 which doesn't exchange the values of the first two elements.

For II the first line of code

int t= a[0]; saves the original value of a[0] to t, so we get t=1.

the second line of code

a[0]=a[1]; changes the value of a[0]  to that of a[1]. Thus, in our example a[0]=2.

the final line

a[1]=t; changes the value of a[1] to the original value of a[0], giving us a[1]=1 and a[0]=2, what we were looking for.

For III

the first line of code

a[0]=a[0]-a[1];

gives us

a[0]=1-2

the secon line

a[1]=a[1]+a[0];

takes the new value of a[0] and replaces it in the expression

a[1]= 2+(1-2)=1

the last line

a[0]=a[1]-a[0];

takes the new value of a[0] and a[1] and replaces the in the expression

a[0]=1-(1-2)=1-1+2=2

which exchanges the values needed.

So we can see that only II and III do what we require, giving us E as the answer.

You might be interested in
Please I will give brainliest
Dimas [21]
The answer is 96 square ft
4 0
3 years ago
What is this answer please help me
Deffense [45]

Answer:

It is proportional

Step-by-step explanation:

To determine if its proportional/non-proportional is by using ratios

so go line by line

p pine and k oak

12 pine to 44 oak

18 pine to 66 oak

24 pine to 88 oak

30 pine to 110 oak

Start with the first line

p= pine per k= oak

so obviously not numbers but to help mind you it just means the numbers will be put as p/k (to make life simpler)

Or pine over oak

Second Line

12/44 which reduces down to 3/11

Third Line

18/66 which reduces down to 3/11

Fourth line

24/88 which reduces down to 3/11

Fifth line

30/110 which reduces down to 3/11

In order to be proportional the ratios all have to be equivalent to each other

Therefore,

3/11 = 3/11 = 3/11 = 3/11

So this is proportional

5 0
3 years ago
Solve please x-6=√6+4
Westkost [7]

Answer:

Why’s she did mjd673!

Step-by-step explanation:

&3$83!494’r

8 0
3 years ago
20 divided by 3 but the answer is a fraction
nata0808 [166]
33/5 hope that helppssssssss

8 0
3 years ago
Read 2 more answers
If you know that 8x300=2400 how can you find 8x320
34kurt
If you knew that 8*300=2400

Then you could likely figure that 8*20=160

And then just add the two together to get 2560
8 0
3 years ago
Read 2 more answers
Other questions:
  • Which expression is equivalent to 8/9 divided by 3/4
    13·2 answers
  • HELP PLEASE WILL MARK BRAINLIEST!!
    11·1 answer
  • Please Help Me
    7·1 answer
  • Two women equally shared 1/4 cake how much cake did each woman get
    15·2 answers
  • The problem involves empirical probability. The table shows the breakdown of 95 thousand single parents on active duty in the U.
    6·1 answer
  • The ________ of two events X and Y is another event that consists of the sample space outcomes belonging to either event X or ev
    13·1 answer
  • If y = 2x2 – 4x, what is the value of y when x equals 5. <br> A.10 <br> B.30 <br> C.80 <br> D.480
    5·1 answer
  • What is the area of the rectangle
    5·2 answers
  • Please help will mark brainliest
    9·2 answers
  • Give an example of a number between 20 and 50 which is a multiple of 3 and also a factor of 84.​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!