Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How do we swap or interchange any 2 numbers without using
Temporary variable...Anybody can pls answer it.. Thanks in
Advance

Answer Posted / emperor of america

using bitwise operator works 100%:
x^=y;
y^=x;
x^=y;

using +/- works sometime, need to consider overflow.

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose of the preprocessor directive error?

1200


What is substring in c?

1132


When is a “switch” statement preferable over an “if” statement?

1072


code for quick sort?

1985


Explain the difference between exit() and _exit() function?

1109


What are data structures in c and how to use them?

1094


What is the importance of c in your views?

1094


What are the 4 data types?

964


What is the difference between declaring a variable and defining a variable?

1186


What are c preprocessors?

1125


What is the best way to store flag values in a program?

1010


Where is volatile variable stored?

1026


Is there anything like an ifdef for typedefs?

1094


What does stand for?

1045


Which is better between malloc and calloc?

1120