Is there any built in swap function in C which works without using a third variable?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No.
C++ builtin swap function:
swap(first,second);Check this: http://www.cplusplus.com/reference/algorithm/swap/
You can use this to swap two variable value without using third variable:
You can also check this:
https://stackoverflow.com/questions/756750/swap-the-values-of-two-variables-without-using-third-variable
How to swap without a third variable?