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 / mansi_engg

use unsigned before variable a and b in
a=1;
b=32767;
a=a+b;
b=a-b;
a=a-b;
bcoj 32767+1 =32768 which goes out of range of integer and
will be stored as -32768 which wil make the swapping
wrong.by using unsigned, addition will come in range 0-65536
and thus the process works.

Is This Answer Correct ?    8 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is function prototype in c with example?

1005


Is null a keyword in c?

1140


How to write a code for implementing my own printf() and scanf().... Please hep me in this... I need a guidance... Can you give an coding for c... Please also explain about the header files used other than #include...

5406


What is use of bit field?

1237


How can a process change an environment variable in its caller?

1132


how logic is used

1920


Where static variables are stored in c?

1044


What is the general form of #line preprocessor?

950


What 'lex' does?

1103


What is the modulus operator?

1154


Explain how can I write functions that take a variable number of arguments?

1032


What is nested structure with example?

1016


What are the types of i/o functions?

1256


How can I swap two values without using a temporary?

1063


What is a struct c#?

1001