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
What is the solution of this equation?<br> 8p-8=-9(2p+5)-9(6-3p)
Sav [38]
8p-8=-9(2p+5)-9(6-3p)
p=91
I showed the work up there and checked

8 0
3 years ago
Value expressions-10-(-4)=
Vinvika [58]

Answer:

6

Step-by-step explanation:

5 0
3 years ago
Read 2 more answers
Applying Rate of change
olga nikolaevna [1]
\bf \begin{array}{ccllll}&#10;minutes(x)&Mbs\ left(y)\\&#10;-----&-----\\&#10;2&38.4\\&#10;8&9.6&#10;\end{array}\\\\&#10;-----------------------------\\\\&#10;slope = {{ m}}= \cfrac{rise}{run} \implies &#10;\cfrac{{{ y_2}}-{{ y_1}}}{{{ x_2}}-{{ x_1}}}\impliedby \textit{rate of change}&#10;\\\\\\&#10;m=\cfrac{9.6-38.4}{8-2}\implies m=-\cfrac{24}{5}\iff m= -4.8

now, notice, the rate of change for downloading is negative, because, "y" is decreasing,  namely the Mbs to be downloaded, are less and less and less as the minutes go by, because the file is almost fully downloaded

so is -4.8

now... at 8minutes, there are 9.6Mbs to download
bear in mind that 9.6 is just 4.8 * 2
that simply means, another minute, another 4.8 Mbs, and another minute and another 4.8 Mbs and the file is done

so, the file downloaded really in 10minutes

now, we know the rate is -4.8 or -24/5,   let us nevermind the sign for now

since we know the file is downloading at 24Mbs in 5minutes, a rate of 24/5

how much is it for 10 minutes?   well 10 is really just 5 * 2

so if it downloads at a rate of 24Mbs per 5mins, in 10 minutes it downloaded 24*2 or 48Mbs
7 0
3 years ago
Is 6(6+x) equivalent to 6x+36
Ray Of Light [21]
Close enough, it would be 36+6x.
5 0
3 years ago
Read 2 more answers
What are the dimensions of the base of the pyramid?
eimsori [14]
I hope the picture helps

7 0
3 years ago
Other questions:
  • Someone please help me with my homework please please help please help me with my homework
    14·1 answer
  • John has 3 apple he gives 2 to his brother. How many apples does he have?
    10·2 answers
  • PLEASE HELP WITH 7&amp;8
    6·1 answer
  • 7,423.28 fraction form
    5·2 answers
  • A yard is equal in length to three feet. The function f(x) takes a measurement
    10·1 answer
  • Give an exact answer please and thanks you
    15·1 answer
  • Given an equilateral triangle with two vertices located at (-8, -5) and (3, 7), what is its perimeter?
    13·1 answer
  • Sherita needs 1 3/5 cups of sugar. she has 8 cups of sugar. how much cups can she make?
    9·2 answers
  • PLEASE HELP, WILL MARK AS BRAINLIEST !! (QUESTION IN THE PICTURE)
    7·1 answer
  • Find the term to term rules for the following sequences. 28 25 22 19 16 .​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!