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...

write a program to swap Two numbers without using temp variable.

Answer Posted / guest

using xor technique is much faster than using addition and
subtraction process , and xor instruction is much simpler at
processor level.

so be simply

x = x xor y
y = x xor y
x = x xor y

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you do dynamic memory allocation in C applications?

1044


Write a program to reverse a given number in c language?

1049


Is c is a procedural language?

1033


Are pointers really faster than arrays?

965


Implement bit Array in C.

1096


Explain what are the advantages and disadvantages of a heap?

1031


Differentiate between full, complete & perfect binary trees.

1052


What are the advantages of external class?

1004


What is a buffer in c?

946


Can include files be nested?

1058


What are the Advantages of using macro

1114


What is property type c?

1045


What is the correct code to have following output in c using nested for loop?

1027


What library is sizeof in c?

1036


what will be maximum number of comparisons when number of elements are given?

1849