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

Kathy is baking cakes. Each cake requires 1/12 of a teaspoon of vanilla, and she has 9/12 of a teaspoon, how many cakes can she bake?
Taylor was thirsty and decided to mix up a pitcher of lemonade. She put lemon juice, water, and sugar into a pitcher and stirred it to create this wonderful new
Saul has 130 baseball cards. How many baseball cards does he need to get so that he will have 200 baseball cards in all?
what elements are most abudant in living organisms
Help me please please help me due tomorrow
What is the difference between accurate data and reproducible data?
a 0.640 m aqueous solution freezes at –3.30 °C, what is the van\'t Hoff factor, i, of the solute?
The answer how you set it up
is 0.1292387523 a rational number
What value of x makes the equation true? 1/2(4x−5)+5/2=10