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 in C to swap two variables

Answer Posted / muzammil

Here are some LOGICS to swap two nmbrs

1) a+=b; b=a-b; a-=b;
2) a*=b; b=a/b; a/=b;
3) a=a^b; b=a^b; a=a^b;

Now Single line statements

4) a=a-(b=(-b+(a=a+b)));
5) a=a^(b=(b^(a=a^b)));
6) b=a+b-(a=b); This one was posted BY Senthil Thanks to him
7) b=a*b/(a=b); Dis is same as above one except for da
operators.

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

difference between Low, Middle, High Level languages in c ?

2079


Explain function?

1083


What are header files why are they important?

1086


provide an example of the Group by clause, when would you use this clause

2188


What is spaghetti programming?

1127


What is the main difference between calloc () and malloc ()?

1147


how do you programme Carrier Sense Multiple Access

1966


What is pointer to pointer in c language?

1136


Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

5947


Write a program to reverse a string.

1071


What is the difference between text files and binary files?

1346


What is the general form of function in c?

1020


What is the heap in c?

1077


Differentiate Source Codes from Object Codes

1563


What is the method to save data in stack data structure type?

1081