Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   give me program coding for this prog plz (http://www.go4expert.com/forums/program-coding-prog-plz-t23132/)

parthahir 29Aug2010 09:38

give me program coding for this prog plz
 
how can i interchang any 2 numbers????
with out taking any variable?????
plz ans me its urjent

xpi0t0s 29Aug2010 13:31

Re: give me program coding for this prog plz
 
One way is to use the xor operation, although it doesn't always work:
Code:

a^=b;
b^=a;
a^=b;

You should find out under what circumstances it doesn't work (by testing that is, not by posting "give me coding plz" somewhere).

LordN3mrod 7Sep2010 00:54

Re: give me program coding for this prog plz
 
Yet another way is
a = a + b;
b = a - b;
a = a - b;


All times are GMT +5.5. The time now is 16:08.