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

What is the maximum of relative extrema 3x^4-x^2+4x-2
17. One way to manage a child who interferes with others is to A. allow the child to wander around. B. help the child find a companion. C. separate the child
list three ways to prevent body odor
Find the midpoint of the line segment from (-7,3) to (-4,2)
Can someone help me answer questions 10 and 11?
Can someone help me with this question?
¿Qué costumbre gallega que se hace cada año por todas partes de Europa?
The sale price of last year’s hottest game is 30% off the retail price. The game sold last year for $86.00. What is the sale price?
A car on the highway slows for 32.0 m/s to rest as the driver approaches a traffic jam. The car has 70.0. To stop. A.Solve for the acceleration needed to stop t
Given the ordered pair P, determine the requested sin, cos, or tan of angle . P(-5, -3) tan = -3/5 -5/3 3/5 5/3