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 / yash paranjape

a=a^b;
b=a^b;
a=a^b;


i.e
a^=b;
b^=a;
a^=b;

more simplifie i.e in just one line
a^=b^=a^=b;

This also works fine

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

in linking some of os executables are linking name some of them

2096


What is void main () in c?

1172


How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

995


How is a macro different from a function?

1141


Difference between constant pointer and pointer to a constant.

1093


What are the different types of endless loops?

1047


while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above

1211


What is operator promotion?

1031


Can the curly brackets { } be used to enclose a single line of code?

1144


What is the use of printf() and scanf() functions?

1096


what are bit fields in c?

1638


Write a code to generate divisors of an integer?

1027


What is the difference between c &c++?

1114


What are directives in c?

943


Explain what are global variables and explain how do you declare them?

1119