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...

write a program to swap Two numbers without using temp variable.

Answer Posted / jaspreet singh

hey prasanna the program you hv writen is correct but this
method fails when we give the input as a=32767 and b=1

the correct method is
a^=b^=a^=b

or
a=a^b;
b=a^b;
a=a^b;
it will always return the correct answer even if the input
is a=32767 and b=1...............

Is This Answer Correct ?    17 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?

1092


What are the types of data files?

1207


What is New modifiers?

1135


How can I implement sets or arrays of bits?

1049


Write a program to print fibonacci series using recursion?

1069


Tell me what is the purpose of 'register' keyword in c language?

1012


What are the rules for the identifier?

1172


Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.

3695


How do I create a directory? How do I remove a directory (and its contents)?

1175


If I have a char * variable pointing to the name of a function ..

1177


What does int main () mean?

1035


What is the use of void pointer and null pointer in c language?

1128


Explain enumerated types in c language?

1057


What is a structure member in c?

1011


What is array of structure in c?

1189