# How to replace Variable With Variable [closed]

Clear[a, b, c];
a = c;    a =. ;    b = a;    b =.;    c = b;    c =.;
Print[a, b]


and the result is

{a b}

but I want the result {b a} by using a Temp help. how is the code suppose to be?

## closed as unclear what you're asking by Daniel Lichtblau, Henrik Schumacher, MarcoB, Coolwater, m_goldbergApr 18 '18 at 19:33

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Is this what you need? Print[a, b] // Inactivate // Reverse // Activate – Kuba Apr 18 '18 at 8:42
• i dont get it, the expample is i want to Give the value of A to Temp, Then give the Value of B to A, and C to B and the last Temp to C. so the result if i Print[A,B] its will result B,A . And also work if i input values – Bagoes Heikhal Apr 18 '18 at 8:56
• I don't think it makes sense unless a/b/c have values. Can you provide a small example? – Kuba Apr 18 '18 at 9:02
• {a, b, c} = {b, c, a};? – Kuba Apr 18 '18 at 9:06
• Unclear what is wanted that would not induce infinite recursion. Maybe something like this (also suggested by @Kuba)? In:= x = 3; y = 5; {x, y} = {y, x}; {x, y} Out= {5, 3} – Daniel Lichtblau Apr 18 '18 at 13:56

Clear[a, b]
a := Defer[b]; b := Defer[a];
Print[a, b]


ba

With values

Clear[a, b, c]
a = 1; b = 2;
c = a; a = b; b = c;
Print[a, b]


21

• How to make its work if i input the variable with values – Bagoes Heikhal Apr 18 '18 at 8:59

I don't think the output the OP has in mind is possible within reasonable bounds of normal programming. If you want a to evaluate to b and b to evaluate to a, the evaluation chain will never end.

If you're only interested in the output, use Defer:

a = Defer[b];
b = Defer[a];
Print[a, b]