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

How do I round numbers?

602


Explain void pointer?

593


What is an endless loop?

805


What is clrscr ()?

640


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

1845






Is it possible to have a function as a parameter in another function?

600


What is nested structure with example?

626


When should the register modifier be used? Does it really help?

616


What is ambagious result in C? explain with an example.

2058


Can you please compare array with pointer?

618


What is string function c?

569


How can I remove the trailing spaces from a string?

617


What is the difference between the local variable and global variable in c?

533


‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

1880


What is storage class?

655