Dev Kashyap wrote:
> [mod-- Before replying to this post, please read the file
> swapnotemp.html in the html folder of the Files section
> of C-Prog... <http://tech.groups.yahoo.com/group/c-prog/files>
> --mod PN]
> 
> Hi friends!!
>  
> i want to  know what is the different methods  to swap two numbers-
> one is using temp variable.
> second is by using xor 
> third is by using + and -.
> plz tell me wheather there  is another method to swaping. 
>  
> Thanks 
> With Regards 
> Dev kashyap 

For those too lazy to log into Yahoo, here's a direct link:

http://f1.grp.yahoofs.com/v1/4OJ4S_cXRAttP226dTISG7fYU4tgouBzcWcpJBnnDGAOqYfy1Zfiph9NmRQIEYtHP-fkgmFF5hreGXmCQ2Yl/html/swapnotemp.html

To summarize:  Don't do stupid cutesy tricks.  Best case:  You will 
create broken code that appears to work most of the time.  Worst case: 
You will get fired.  Or murdered - "Write code like the next person who 
has to maintain it is a serial killer who knows where you live".  There 
is exactly ONE correct way to swap two numbers.  Occam's razor.

You would be surprised how often this question comes up on this group 
and how often we have to correct the many people who reply.

I'm CC'ing this to the teacher who was on this list recently wanting 
problems for assignments.  Teachers, this is the sort of question to NOT 
ask students.

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to