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
Solved

with using temp

Posted on 1998-12-12
5
179 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 50 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files 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.

861 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