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

Do you think the atomic bomb on Hiroshima was worth it? Why or why not?
what is 480 divided by 1/3?
A device for transmitting long and short currents over wires was invented by Michael FaradaySamuel MorseNikola Tesla.
The control center and director of cell activities is the _____. endoplasmic reticulum nucleus mitochondria lysosomes
Why is the federal income tax a progressive tax? A. A higher income has more deductions. B. A higher income pays a lower rate. C. Corporations can lower their
botanophile love what is it means.
A radio is on sale for $50. If this price represents a 10% discount from the original price, what is the original price to the nearest nickel?
What was the name of the scandal that forced President Nixon to resign? User: Who from each Cabinet department is responsible for reporting to and advising the
y/4+−49=−9 y= This is a two step equation again from vmathlive
How did the seamounts form near the marianas trench?