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 to swap two numbers with out using temp variable

Answer Posted / a.g.dhivyalakshmi

//swaping of 2 numbers without using temp variable
//a=5 & b=6
a=a+b; //a=30
b=a-b; //b=5
a=a-b; //a=6

//Thus two numbers are swapped

// or
//a=5 & b=6
a=a*b; //a=30
b=a/b; //b=5
a=a/b; //a=6

//Thus two numbers are swapped

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the default access level?

1116


What is abstract class in c++?

1134


What do you mean by storage classes?

1651


Is swift faster than c++?

1070


Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?

1185


Who created c++?

1113


What is a container class? What are the types of container classes in c++?

1360


What is the use of cmath in c++?

1115


Why do we need runtime polymorphism in c++?

1071


What is a local variable?

1131


Can we delete this pointer in c++?

1271


What is the use of endl in c++?

1062


What are c++ manipulators?

1117


How do you declare A pointer to function which receives an int pointer and returns a float pointer

1277


What is data abstraction? How is it different from data encapsulation?

1045