Answer:
see explanation below.
Step-by-step explanation:
I have two variables, $x$ and $y$, and I want to swap their values.
For example, if $x$ has value 5 and $y$ has value "banana", then after the swap I want $x$ to have value "banana" and $y$ to have value 5.
1. Explain why the code x = y y = x doesn't work,
2. figure out what we need to do to swap the values of $x$ and $y$.
1. the code x=y means a copy of the y-value ("banana") to x
after this step, both variables x and y will have the value "banana".
Evidently the next step y=x will recopy the copied value of "banana" in x back to y.
Net result, both variables will contain "banana", not an exchange.
2. The code that will work requires a third temporary variable, say t.
We can then do a circular copy, starting with assignment of t.
t=x (t now contains 5)
x=y (x now contains "banana")
y=t (y now contains 5)
Thus the exchange is now complete.