How to swap two variables, without using third variable ? Hi this question was asked in my interview. Ans is : a=a+b; b=a-b; a=a-b; Any other solution? a=a*b/(b=a); b=(a+b)-(a=b); use xor to swap a = a^b b= a^b a= a^b Ans is : a=a*b; b=a/b; a=a/b;
--
http://www.venkatmails.blogspot.com/
Venkat Mails, Fun , Cool pictures, Fun messages, Sardar Jokes, Quotations Moral stories Fun stories
http://www.venkatmails.blogspot.com/
No comments:
Post a Comment