Could you explain the question a bit better, please? It isn't clear just what you are looking for, especially what you mean by 'execute first'. That last part sounds like your professor's instructions to you rather than a part of the question.
I assume you are asking, how would you write the code for this, but frankly, the first part sounds trivial; you would simply assign the first variable's value to the temporary variable, then assign the second variable's value to the first variable, then finally assign the temp variable's value (which is holding the first's old value, remember) to the second variable.The only possible complication I can see is if you are writing it as a function, in which case you would have to pass the variables by reference (that is to say, using pointers to the actual variables rather than copies of the values).
As for swapping without a temporary variable, the usual approach in C is to use a trick involving the XOR operator (^
), but I'll leave it to you to figure it out. I will warn you that the XOR trick isn't necessarily more space efficient than the temp variable version (because of certain optimizations the compiler can use involving internal registers), and it has a potential to backfire - if the two values are already the same, then XORing them will give a result of zero. It's the sort of kludgy optimization that you are unlikely to bother with on a modern system, because …