Thursday, 4 September 2014

A simple logic to swap two numbers without using a 3rd variable

An operation which uses only two variables like swapping etc. are done by using repeated similar operations with tjose of same variable. The codes goes like this :
1.x=x+y;  2. x=x*y; 
   y=x-y;       y=x/y;
   x=x-y;       x=x/y;

0 comments :

Post a Comment