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

the product of 11 and n
7x - 4 and 5x + 4 are the lengths of two of the sides of a rhombus. What is the value of x? If there is not enough information to find x, enter 999.​
How is the Magna Carta a document that paved the way for the modern democratic system? Please be hurry, I'm doing a quiz with only 16 minutes remaining
Arrange the following ions in order of decreasing charge density; 2+, 2+, 3+ 2+
11/12 yards of material how many blankets can i make if i have 19 yards
positive integers greater than -4​
What are protein made of?
At Fiona's Flavors, you can make 792 different five-scoop bowls of ice cream. How many different five-scoop ice cream cones can you make?
What is 85% of £60?? I NEED HELPPP
write a letter to your friend describing the importance of religious tolerance ​