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

How do I run c++?

1015


What is encapsulation in c++ with example?

974


Which software is best for programming?

1109


Is there any function that can skip certain number of characters present in the input stream?

1027


Why do we use double in c++?

1021


Can you pass an array to a function in c++?

972


What do you mean by funtion prototype?

1020


What is the difference between the parameter to a template and the parameter to a function?

1076


What is c++ array?

1052


Write a Program for find and replace a character in a string.

1035


What is vector processing?

1123


What are the various compound assignment operators in c++?

949


State the difference between delete and delete[].

1061


What is the difference between struct and class?

1459


What is else syntax in c++?

1142