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 integers 1 and 32767 without using third
variable

Answer Posted / sharath kumar

As int max valur is 32767. If we increment it it becomes -32768, so its a wrong way to do

a=1; b=32767;
a=-a; b=-b;
a=a+b; //-32768 with in range
b=a-b; //-1
a=a-b; //-32767
printf("%d%d",-a,-b);

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between arrays and pointers?

1144


What is the meaning of c in c language?

1182


What is static and auto variables in c?

1101


How does free() know explain how much memory to release?

1069


Does c have an equivalent to pascals with statement?

1019


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

1246


What is the use of the function in c?

1032


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

1288


What are types of structure?

1138


How would you use the functions fseek(), freed(), fwrite() and ftell()?

1169


What is meant by type specifiers?

1143


Is c call by value?

1033


What is the role of this pointer?

1086


Is there sort function in c?

1030


What is this pointer in c plus plus?

1105