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

How to solve. -3(4r-8)= -36
The Midwest is one region of the United States.what characteristics make it a region?
please I need help on 2 multiple choice question about a book Angela's Ashes. 1—In Angela's Ashes what sort of treatment does Frank receive for his typhoid feve
A sports agent made one million dollars by charging a 12.5% commission to negotiate a long-term contract for a professional athlete. Find the amount of the cont
please I need help on 2 multiple choice question about a book Angela's Ashes. 1—In Angela's Ashes what sort of treatment does Frank receive for his typhoid feve
how do you simplified 7a(3b-2c+4)
How to solve. -3(4r-8)= -36
(8.41 x 10 to the fourth) + (9.71 x 10 to the fourth)
With a manual transmission, the speed of the vehicle determines
How can archaeologists continue to study ancient remains without infringing on the rights of Native Americans?