[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

with using temp

Posted on 1998-12-12
5
Medium Priority
?
187 Views
Last Modified: 2010-04-15
give two functions to swap variables without using temp variables
0
Comment
Question by:jit1
5 Comments
 

Author Comment

by:jit1
ID: 1255059
please give answer to this Q
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 1255060
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
 
LVL 8

Expert Comment

by:Answers2000
ID: 1255061
XOR algorithm, a sequence of XORs let's you swap variables with a temp in disk or memory
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 100 total points
ID: 1255062
>> 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
 
LVL 1

Expert Comment

by:sergelebel
ID: 1255063
use inline assembly

asm {
    push Variable_A
    push Variable_B
    pop   Variable_A
    pop   Variable_B
}


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question