Given two numbers X and Y in the computer memory Exchangeswa

Given two numbers X and Y in the computer memory. Exchange/swap these two units of memory, i.e., get Y and X without using any extra memory.

E.g. you can use X = X+Y, but you cannot use Z= X since Z is forbidden

Solution

Okay.There are two numbers X and Y.Then,the swap of these two units of memory without using any extra memory can be done as following :

Example:

let X=10;Y=15;

After following the given steps:

Given two numbers X and Y in the computer memory. Exchange/swap these two units of memory, i.e., get Y and X without using any extra memory. E.g. you can use X

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site