Solved

with using temp

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
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.

809 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