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

In a header file whether functions are declared or defined?

1096


What are the main characteristics of c language describe the structure of ac program?

1173


Are comments included during the compilation stage and placed in the EXE file as well?

1051


What are dangling pointers? How are dangling pointers different from memory leaks?

1262


write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1

3883


Can two or more operators such as and be combined in a single line of program code?

1327


Explain what are multibyte characters?

1137


Write a program that accept anumber in words

1724


In a switch statement, what will happen if a break statement is omitted?

1034


What is the most efficient way to store flag values?

1149


Do array subscripts always start with zero?

1256


Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

1061


How macro execution is faster than function ?

1154


What are the advantages of the functions?

1120


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1181