Swap Two Numbers

Practice this coding question on Coding Gurukul.

Problem statement

A laboratory has two labelled storage positions, A and B. Their recorded readings were assigned to the opposite positions and must be exchanged. Your task Read the two integer readings and swap their values. Output the new value of A followed by the new value of B. Important details Only the positions change; neither reading is recalculated or discarded. Equal readings remain equal after the exchange. Zero and negative readings are ordinary values, not missing-data markers. You may use a temporary variable, which also avoids overflow that an arithmetic swap could introduce. Preserve the requested output order even when the first reading is larger. Worked example If A initially holds 12 and B holds -4, exchanging them leaves A = -4 and B = 12, so print -4 12.

Input format

One line contains A and B.

Output format

Print the two values after swapping, separated by a space.

Constraints

-1000000000 <= A, B <= 1000000000.

Sample input

12 -4

Sample output

-4 12

Sign in to run or submit a solution in C++, Java or Python.