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 %g in c?

1078


How will you write a code for accessing the length of an array without assigning it to another variable?

1044


how to execute a program using if else condition and the output should enter number and the number is odd only...

2295


In which header file is the null macro defined?

1341


What do you mean by scope of a variable in c?

1010


what is the difference between class and unio?

2360


What is pointer in c?

1192


How can I prevent another program from modifying part of a file that I am modifying?

1056


What is the heap?

1216


What is auto keyword in c?

1206


What is the use of ?: Operator?

1137


How do you define a string?

1101


A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler

1092


Why isnt any of this standardized in c?

1075


Write a program to check prime number in c programming?

1090