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
Kuri spent a total of $68 on trading cards. His collection contains two types of cards. A pack of trading card A cost $4, and a
devlian [24]
4a+7b=68 go to mathpapa
8 0
3 years ago
Read 2 more answers
I have two fair dice both numbered 1 to 6. I throw both dice and add both numbers together. What is the probability that the num
Alex17521 [72]

Answer:7/36

Step-by-step explanation:

Firstly, I would draw a table to visually see what the outcomes are. There are many methods but this is what i find to be the easiest so here it goes!!!

I hope the pic helps! If you have any questions feel free to ask!

7 0
3 years ago
The outside of a picture frame measures 14 in and 20 in 196in^2 of the picture shows find the thickness of the frame
LuckyWell [14K]
The described picture frame can be visualized into two separate parts. The first area is equal to the area using the outermost dimensions for the length and width. 
             Area = Length x Height
              Area = (20 in) x (14 in) 
              Area = 280 in²

We are given that the area is only equal to 192 in². We subtract this value from the computed area.
         Difference = 280 in² - 192 in²
               difference = 88 in²

This area is equal to the area of the hollow space inside the frame. That is equal to,
      height = 20 in - 2x
      length = 14 in - 2x

The area,
               88 = (20 - 2x)(14 - 2x)

Simplify the right hand side of the equation.
             88 = 280 - 68x + 4x²

Divide the equation by 4,
            22 = 70 - 17x + x²

Transposing,
                x² - 17x - 48 = 0
The factors of the equation is 58.2. 

Thus, the thickenss is equal to 58.2 in
5 0
3 years ago
Hi friends,
Mkey [24]

Answer : 19.6cm

I hope this helps you! Have a good day!

6 0
2 years ago
I'm abt to burn my house down follow my insta, rsokolskiy9, for the full video
ELEN [110]

Answer:

oh my

Step-by-step explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • A jar of sweets contains 5 yellow sweets, 4 red sweets, 8 green sweets, 4 orange sweets and 3 white sweets. Ola chooses a sweet
    11·1 answer
  • Help please please please:((((
    12·1 answer
  • devante is 26 years younger than Ariana. 2 years ago Arianas age was 2 times devantes age. how old is devante now
    5·1 answer
  • Plz help ill give brainlist to you
    12·1 answer
  • -a/2=10 what is the value of a
    10·1 answer
  • The length of a rectangler picture is 5 inches more than three times the width find the dimensions of the picture if its perimet
    12·1 answer
  • I idk how to put this please help me understand better
    13·1 answer
  • The midpoint of AB is M(1,-2). If the coordinates of A are (-3, -8), what are the coordinates of B?​
    5·1 answer
  • Comparing Rational Numbers
    5·1 answer
  • Drag and drop the correct answer​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!