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
Nikitich [7]
3 years ago
9

I have two variables, $x$ and $y$, and I want to swap their values. (For example, if $x$ has value 5 and $y$ has value "banana",

then after the swap I want $x$ to have value "banana" and $y$ to have value 5.) Explain why the code x = y y = x doesn't work, and figure out what we need to do to swap the values of $x$ and $y$.
Mathematics
1 answer:
IgorLugansk [536]3 years ago
3 0

Answer:

see explanation below.

Step-by-step explanation:

I have two variables, $x$ and $y$, and I want to swap their values.

For example, if $x$ has value 5 and $y$ has value "banana", then after the swap I want $x$ to have value "banana" and $y$ to have value 5.

1. Explain why the code x = y y = x doesn't work,

2. figure out what we need to do to swap the values of $x$ and $y$.

1. the code x=y means a copy of the y-value ("banana") to x

after this step, both variables x and y will have the value "banana".

Evidently the next step y=x will recopy the copied value of "banana" in x back to y.

Net result, both variables will contain "banana", not an exchange.

2. The code that will work requires a third temporary variable, say t.

We can then do a circular copy, starting with assignment of t.

t=x   (t now contains 5)

x=y  (x now contains "banana")

y=t   (y now contains 5)

Thus the exchange is now complete.

You might be interested in
Answer this please pretty please​
Slav-nsk [51]

Answer:

Wassup Obito

Step-by-step explanation:

I would have done it if you had asked for only 1 question but you have asked someone to do more than 10 q

You must be mad to think someone will do the entire thing

Mark me brainliest

8 0
3 years ago
I’ve been stuck can someone explain
MariettaO [177]

Answer:

Option (3)

Step-by-step explanation:

From the figure attached,

AB and CD are two chords intersecting at O.

m∠AOD = 37°

m∠AOC + m∠AOD = 180° [Since these angles are supplementary angles]

m∠AOC = 180° - 37°

              = 143°

By the theorem of intersecting chords,

Measure of angle formed is the half of the sum of measures of the arcs intercepted by the angle and vertical angle.

m∠AOC = \frac{1}{2}(\widehat{AC}+\widehat{BD})

143° = \frac{1}{2}[(x+5)+(x-5)]

143° = x

Therefore, Option (3) will be the answer.

3 0
3 years ago
For an arithmetic sequence, a35=57. If the common difference is 5. Find a1 and the sum of the first 61 terms.
Flauer [41]

 

\displaystyle\bf\\a_{35}=57\\r=5\\----\\a_1=?\\S_{61}=?\\----\\Solve:\\1)\\a_1=a_{35}-(35-1)\times r=57-34\times 5=57-170=-113\\\boxed{\bf a_1=-113}\\\\

.

\displaystyle\bf\\2)\\A_{61}=a_1+(61-1)\times r=-113+60\times5=-113+300=187\\\\S_{61}=(-113)+(-108)+(-103)+...+(-8)+(-3)+2+7+12+...+187\\\\S_{61}=SA+SB\\\\SA=(-113)+(-108)+(-103)+...+(-8)+(-3)=-(3+8+103+108+113)\\\\n=\frac{113-8}{5}+1=\frac{105}{5}+1=21+1=22~terms\\SA=-\Big( \frac{n(113+3)}{2} \Big)=-\Big( \frac{22\times116}{2} \Big)=-11\times116 =-1276

.

\displaystyle\bf\\SB=2+7+12+...+187\\\\n=\frac{187-2}{5}+1=\frac{185}{5}+1=37+1=38~terms\\\\SB=\frac{n(187+2)}{2}=\frac{38\times189}{2}=19\times189=3591\\\\S_{61}=SA+SB=-1276+3591=2315\\\\\boxed{\bf S_{61}=2315}    

 

 

8 0
3 years ago
A multiple choice test contains 25 questions with 5 answer choices. What is the probability of correctly answering 8 questions i
klio [65]

Answer: 0.0623

Step-by-step explanation:

5 0
3 years ago
Hep I’ll give brainliest
PilotLPTM [1.2K]
Use this to help you.

6 0
3 years ago
Read 2 more answers
Other questions:
  • The perimeter of a rectangular slab of concrete is 24 meters. If the length of the
    14·2 answers
  • The sides of a triangle are in the ratio 2:3:5. The perimeter of the triangle is 55
    11·1 answer
  • What is 3.56×10 to the -5th power in standard form
    8·1 answer
  • 6) Find the surface area of the square pyramid.<br>8 cm<br>5 cm<br>​
    15·1 answer
  • I need help quick for this math question
    9·2 answers
  • Sally is 54 years old and her mother is 80, how many years ago was Sally’s mother times her age?
    11·1 answer
  • A rectangular shape perimeter of 72 metre if the length of diagonal is 18 what is the area of the plot​
    9·1 answer
  • A gym membership costs for $40 for each month.
    10·1 answer
  • Hel]pppppppppppppp timed plz hurry
    14·1 answer
  • PLEASE I DESPERATELY NEED HELP MY ASSIGNMENT IS DUE TOMORROW I WILL MARK YOU AS BRAINLIEST WHOEVER ANSWERS FIRST PLEASEEEEE
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!