BobbyBuckets2186 BobbyBuckets2186
  • 15-08-2019
  • Computers and Technology
contestada

11. Describe an algorithm that interchanges the values of the variables x and y, using only assignments. What is the minimum number of assignment statements needed to do this?

Respuesta :

Mustela Mustela
  • 25-08-2019

Answer:

Following is the algorithm to interchange the value of two variable x and y.

step 1:Read the two integer x and y.

step 2 :t=x

Step 3: x=y  

step 4: y=t

The minimum number of assignment to do this is 3

Explanation:

After reading two integer x & y, create a variable "t" of integer type.

with the help of variable "t", we can swap the value of variable x and y.

It requires 3 assignment to interchange the value.

Answer Link

Otras preguntas

Identify 2 ways hydrogen could be used as a fuel sources in the future ?
Which best describes what the Bill of Rights does for citizens’ rights?
James has purchased a 10-year bond that pays a $50 coupon. If interest rates go up, __________. the bond price will go up the bond price will go down the bond c
then describe how and when Rome was actually founded
What emperor promoted Christianity and joined the church on his deathbed?
Who was the leader of the Polish movement called "Solidarity"? A. Pope John Paul II B. Lech Walesa C. Karol Wajtyla D. Mikhail Gorbachev
Which two living things are most closely related: a) moth and bird b) clam and fish
A babysitter charges 25% more than her normal hourly rate on Saturday night. Her normal hourly rate is $12.50. Which expression represents how much the babysitt
what multiplies to -32 and adds up to -14
how does the periodic table summarize what we know about elements?