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 setw manipulator in c++?

1074


Would you rather wait for quicksort, linear search, or bubble sort on a 200000 element array? (Or go to lunch...) a) Quicksort b) Linear Search c) Bubble Sort

1041


When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?

1091


What is singleton class in c++?

1038


How const int *ourpointer differs from int const *ourpointer?

1122


What is the difference between while and do while loop? Explain with examples.

1103


What is the protected keyword used for?

1109


What is operator overloading in c++ example?

1128


Why do we use constructor?

1051


Do class declarations end with a semicolon?

1073


What is overloading unary operator?

1083


What kind of jobs can I get with c++?

1112


What is the use of lambda in c++?

1018


What you know about structures in C++?

1073


What is the oldest programming language?

1012