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

Explain what is wrong with this program statement?

1064


What is the difference between c and python?

1096


what are the 10 different models of writing an addition program in C language?

1838


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

1647


What is main () in c?

1005


What is const and volatile in c?

987


c program for searching a student details among 10 student details

2038


Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1

4178


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

1084


Are pointers integer?

957


to find the closest pair

2284


What is static volatile in c?

969


Can the “if” function be used in comparing strings?

975


Can include files be nested? How many levels deep can include files be nested?

1082


How does sizeof know array size?

1066