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

Is anything faster than c?

1062


What do you mean by keywords in c?

1198


What is the best way to comment out a section of code that contains comments?

1388


What is %g in c?

1120


Where static variables are stored in c?

1168


What are two dimensional arrays alternatively called as?

1243


Is printf a keyword?

1259


Is c call by value?

1076


What are operators in c?

1077


What are unions in c?

1083


Explain the difference between malloc() and calloc() function?

1101


What is the meaning of && in c?

1085


What is the difference between typedef struct and struct?

1164


what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)

2465


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

1156