answer.
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]
2 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]2 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
The pizza shop offers a 15 percent discount for veterans and senior citizens. If the price of a pizza is $12, how would you find
Naya [18.7K]
All you would do is times 12 by .15 or 15% you get 1.8 then all you do is 12 minus 1.8 you get $10.20 that is the price of a discounted pizza 

I hope this helps


8 0
2 years ago
Read 3 more answers
Pleasee! Which expression is equivalent to the given expression? Assume the denominator does not equal zero.
Ilia_Sergeevich [38]

Answer:

A. 2y^4 over x^2

Step-by-step explanation:

4x^4y^6 ÷ 7x^8y^2

First, you will find the GCF of the equation which is: 7x^4y^2 .

Then, you will divide both of the equation by the GCF which will become:

14x^4y^6 ÷ 7x^4y^2 = 2y^4

7x^8y^2 ÷ 7x^4y^2 = x^2

Hence, the final answer is 2y^4 over x^2

6 0
2 years ago
Read 2 more answers
A STORE IS GIVING AWAY A $10 COUPON TO EVERY 7TH PERSON TO ENTER THE STORE AND A $25 COUPLON TO EVERY 18TH PERSON TO ENTER THE S
ankoles [38]
<span>The lowest common factor of 7 and 18 is 126 (this is a number that both 7 and 18 multiply into, in fact by each other). This means the 126th person will be the first to get both coupons.</span>
7 0
2 years ago
9. The average diameter of an atom is 2 x 10-8 m. What if the average diameter of an atom was 1 cm? How tall would you be?
ozzi

Answer:

You'd be 2 * 10^{-6} times tall

Step-by-step explanation:

Given

Represent the previous and new diameter by D1 and D2;

D_1 = 2 * 10^{-8}m

D_2 = 1\ cm

To determine how tall you'd be, we need to divide D2 by D1;

Ratio = \frac{D_2}{D_1}

Substitute values for D2 and D1

Ratio = \frac{2 * 10^{-8}m}{1\ cm}

Convert cm to m

Ratio = \frac{2 * 10^{-8}m}{1 * 0.01\ m}

Ratio = \frac{2 * 10^{-8}m}{0.01\ m}

Convert denominator to exponents

Ratio = \frac{2 * 10^{-8}m}{10^{-2}\ m}

Ratio = \frac{2 * 10^{-8}}{10^{-2}}

Apply Law of indices

Ratio = 2 * 10^{-8} * 10^2

Ratio = 2 * 10^{-8+2}

Ratio = 2 * 10^{-6}

Hence;

<em>You'd be </em>2 * 10^{-6}<em> times tall</em>

4 0
2 years ago
Mario has a business selling muffins. Let x be the price of a muffin. Then, the profit P for Mario’s business is given by p(x)=-
Rufina [12.5K]
To make a positive profit p(x)>0 we need to make:
-100 x^{2} +350x-150 \ \textgreater \  0

Now we solve this for x:
-2 x^{2} +7x-3 \ \textgreater \ 0

We have:
a = -2
b = 7
c = -3

We will use formula for quadratic equation:
x_{1} =  \frac{-b+ \sqrt{ b^{2}-4ac } }{2a}  \\  \\  x_{2} =  \frac{-b- \sqrt{ b^{2}-4ac } }{2a}  \\  \\  x_{1} =  \frac{-7+ \sqrt{ 49-24 } }{-4} = \frac{-7+5 }{-4} = \frac{-2 }{-4} = \frac{1}{2}  \\  \\  x_{2} =  \frac{-7- \sqrt{ 49-24 } }{-4}  = \frac{-7-5 }{-4} = \frac{-12 }{-4} = 3

We got two solutions. One is fraction other is whole number. We will not consider fraction because the amount of muffins sold must be whole number. So our solution is:
x>3
5 0
2 years ago
Read 2 more answers
Other questions:
  • a survey of reading habits of 100 students showed that 30 read both comics and novels. 10 read neither comics nor novels and twi
    7·1 answer
  • A school baseball team raised $810 for new uniforms. each player on the team sold one book of tickets. there were 10 tickets in
    13·1 answer
  • What is the value of x which proves that the runways are parallel? What is the measure of the larger angle?
    12·2 answers
  • According to the Fundamental Theorem of Algebra, how many roots exist for the polynomial function?
    14·2 answers
  • Jessie's daughter went to Target and bought $1 or $2 items from the One Spot area. She wants to spend less than $20 at Target
    7·2 answers
  • Algebra. Find the variable in the equation 803 divided by 73=m
    9·1 answer
  • Find the greatest common factor of -30 x4yz3 and 75x4z2
    7·1 answer
  • The graph of f(x) shown below resembles the graph of g(x)=x^3, but it has been vertically stretched. Which of the following coul
    15·1 answer
  • Solve; h=11.23*10^5 pls hlep<br><br> like and a 5 star rate pls
    8·2 answers
  • A decorator wants to line the bottom of 3 drawers with paper. If the bottom of each drawer measures 36 inches by 20 inches, how
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!