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
What is the difference between functions getch() and getche()?
What is the best style for code layout in c?
What is ctrl c called?
What are extern variables in c?
Explain logical errors? Compare with syntax errors.
what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)
What is operator precedence?
What are the different types of control structures in programming?
What do you understand by friend-functions? How are they used?
What is the difference between #include and #include 'file' ?
What are the 5 types of inheritance in c ++?
What is a substring in c?
I need testPalindrome and removeSpace
#include
What are the 32 keywords in c?
What is call by value in c?