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

how logic is used

1914


What is auto keyword in c?

1159


What is echo in c programming?

963


Explain null pointer.

1039


Explain the difference between null pointer and void pointer.

1030


Explain logical errors? Compare with syntax errors.

1009


Here is a good puzzle: how do you write a program which produces its own source code as output?

1033


Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.

3088


What is a floating point in c?

1006


What does 3 periods mean in texting?

1011


Differentiate fundamental data types and derived data types in C.

983


Do pointers need to be initialized?

1017


Here is a neat trick for checking whether two strings are equal

966


How will you declare an array of three function pointers where each function receives two ints and returns a float?

1289


How do I use void main?

1049