• C

with using temp

give two functions to swap variables without using temp variables
jit1Asked:
Who is Participating?
 
heyhey_Connect With a Mentor Commented:
>> give two functions to swap variables without using temp variables

why do you need TWO functions ??

<pseudo code>
a = a XOR b
b = b XOR a
a = a XOR b

0
 
jit1Author Commented:
please give answer to this Q
0
 
AlexVirochovskyCommented:
Look like a homework. But in Assembler: load 2-nd to registre,
move 1-st to 2-nd, save from registe to 1-st.
In C: save 2-nd to disk, move 1-st to 2-nd, read from disk to 1-st.
0
 
Answers2000Commented:
XOR algorithm, a sequence of XORs let's you swap variables with a temp in disk or memory
0
 
sergelebelCommented:
use inline assembly

asm {
    push Variable_A
    push Variable_B
    pop   Variable_A
    pop   Variable_B
}


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.