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 do the problem
The gloom inside the house enveloped me as I stepped through the door. All around I could hear stealthy footsteps and ominous creaking. As an unearthly cry fill
Z=? This topic is angle sum theorem
A mobile travels 98 km in 2h calculate: a) your speed b) how many kilometers will you travel in 3h with the same speed?
how do you do a PowerPoint presentation
Evaluate 12P3 and 10C3
The nurse practitioner is providing care for a patient with a diagnosis of cirrhosis, and he notes that the patient's sclerae are jaundiced. the nurse practitio
An object is launched at 25 m/s from a height of 80 m. The equation for the height (h) in terms of time (t) is given by h(t)= -4.9t^2 + 25t + 80. What is the ob
True or false all squares have four congruent sides .since rectangles are squares all rectangles have four congruent sides
Express each product in the simplest form. (label answer one of a-d)