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
difference between Low, Middle, High Level languages in c ?
Explain function?
What are header files why are they important?
provide an example of the Group by clause, when would you use this clause
What is spaghetti programming?
What is the main difference between calloc () and malloc ()?
how do you programme Carrier Sense Multiple Access
What is pointer to pointer in c language?
Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon
Write a program to reverse a string.
What is the difference between text files and binary files?
What is the general form of function in c?
What is the heap in c?
Differentiate Source Codes from Object Codes
What is the method to save data in stack data structure type?