?
Solved

with using temp

Posted on 1998-12-12
5
Medium Priority
?
183 Views
Last Modified: 2010-04-15
give two functions to swap variables without using temp variables
0
Comment
Question by:jit1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

770 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