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

Why is c called c?

1016


What does a function declared as pascal do differently?

1124


What is a pointer in c?

1554


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

1185


Is there a way to switch on strings?

1083


Write a simple code fragment that will check if a number is positive or negative.

1148


Explain function?

1087


What is non linear data structure in c?

1023


List the different types of c tokens?

1072


Ow can I insert or delete a line (or record) in the middle of a file?

1003


Explain how do you declare an array that will hold more than 64kb of data?

1448


What is difference between structure and union?

1126


Is it possible to initialize a variable at the time it was declared?

1219


What is the difference between typedef and #define?

1055


What is #include conio h?

996