# i gt problem in C Program again !!! HELP ME PLS !!!



## ImBeck (Jul 10, 2008)

How do you exchange or swap TWO (2) variables A and B with using a
third or temporary variable?

C program (Attach TWO (2) sample output for each program)

JUST SHOW ME 2 EXAMPLE OF C PROGRAM


----------



## gary4gar (Jul 10, 2008)

simple, here is a algo & please code the program yourself


> let a=5
> b=6
> a=a+b
> b=a-b
> ...


----------



## RCuber (Jul 10, 2008)

another homework..


----------



## goobimama (Jul 10, 2008)

Why're you making a new thread for this? Post it in that thread you've already created about C...


----------



## QwertyManiac (Jul 10, 2008)

You are seriously asking how to swap *with* a temporary variable and not without?


----------



## Faun (Jul 10, 2008)

^^guess not


----------



## Pathik (Jul 10, 2008)

In that case, 
x=a;
a=b;
b=x;

PS: _Makes me feel like a genius coder._


----------



## MetalheadGautham (Jul 10, 2008)

Pathik said:


> PS: _Makes me feel like a genius coder._



another homework obviously.


----------



## Kl@w-24 (Jul 10, 2008)

Maybe we should create a separate thread: *"Post all your homework questions here"*


----------



## gary4gar (Jul 10, 2008)

abh1shek said:


> Maybe we should create a separate thread: *"Post all your homework questions here"*


Only if you pay me for it


----------



## coolbuddy (Jul 10, 2008)

a=a^b;
 b=a^b;
 a=a^b;


----------



## Garbage (Jul 10, 2008)

coolbuddy said:


> a=a^b;
> b=a^b;
> a=a^b;


won't "+" or "-" operators suffice ?? I think they are less expensive than "^" ...


----------



## QwertyManiac (Jul 10, 2008)

How's addition and subtraction less expensive than an XOR? You've learned your computer architecture properly, haven't you Garbage?  It would result in more gate delays than a simple xor.


----------



## Garbage (Jul 10, 2008)

QwertyManiac said:


> How's addition and subtraction less expensive than an XOR? You've learned your computer architecture properly, haven't you Garbage?  It would result in more gate delays than a simple xor.


I thought he meant "raise to" 

thought it's algorithm than statements...


----------



## gary4gar (Jul 10, 2008)

QwertyManiac said:


> How's addition and subtraction less expensive than an XOR? You've learned your computer architecture properly, haven't you Garbage?  It would result in more gate delays than a simple xor.


yep, Bitwise operations are fastest.
but this things are never taught in our education system
what we learn is using a two and a half decade old program called "TC"


----------



## cooldip10 (Jul 11, 2008)

a thread named "HOMEWORK HELP" must started 

This will save space + other's problems can be reviewed without having to use the search engine


----------



## jal_desai (Jul 23, 2008)

dont u think the question deserved no more than 2 posts.. (this applies to me also for posting *this* useless post)


----------

