Doubt in problem number 4 swapping without 3rd Variable

I saw a solution from the internet but i am not able to get this
#include
using namespace std;

int main()
{
int x = 12, y = 14;

x = x + y; // x = 60
y = x - y; // y = 10
x = x - y; // x = 50
cout << "After Swapping: x = " << x << ", y = " << y;
}
if i take x = 32 and y = 14
then x = x+y which will be 32+14 = 46
similarly y = x-y i.e 46-14 = 18
then x = x-y i.e 46-18 = 28
but when i run the code the ouput shows the swapped numbers. Kindly help me with this. Thanks!

Hey @chitwan_manchanda
Please check your calculations ,u have written this
if i take x = 32 and y = 14
then x = x+y which will be 32+14 = 46
similarly y = x-y i.e 46-14 = 18
then x = x-y i.e 46-18 = 28

What they should be
x=x+y =32+14=46 (correct)
y=x-y=46-14=32 ( but you have written 18 )
x=x-y =46-32 =14

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.