Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 10-07-2008, 01:21 AM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: Jul 2008
Posts: 2
Question i gt problem in C Program again !!! HELP ME PLS !!!


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
ImBeck is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 10-07-2008, 01:24 AM   #2 (permalink)
GaurishSharma.com
 
gary4gar's Avatar
 
Join Date: May 2005
Location: Jaipur
Posts: 4,116
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

simple, here is a algo & please code the program yourself
Quote:
let a=5
b=6
a=a+b
b=a-b
a=a-b
now a=6 and b=5
gary4gar is offline  
Old 10-07-2008, 01:29 AM   #3 (permalink)
Rubik's Uncle!!
 
Charan's Avatar
 
Join Date: Sep 2004
Location: ಬೆಂಗಳೂರು (Bengaluru)
Posts: 3,785
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

another homework..
__________________
i5 2400 | DH67BL | G.Skill Ripjaw 4 GB | FSP SAGA II 500W | CM 430 Black Elite | MSI R6850 Cyclone PE/OC | XBox 360 Controller | 21.5" Samsung Sync Master 2233 | 4 Mbps @75GB FUP :)
Battlefield 3 Multiplayer Discussion | Battlefield 3 Low Latency Servers List
Charan is offline  
Old 10-07-2008, 01:45 AM   #4 (permalink)
 Macboy
 
goobimama's Avatar
 
Join Date: Sep 2004
Location: Goa
Posts: 4,486
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

Why're you making a new thread for this? Post it in that thread you've already created about C...
__________________
I'm like a bird... :)
goobimama is offline  
Old 10-07-2008, 06:19 AM   #5 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

You are seriously asking how to swap with a temporary variable and not without?
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 10-07-2008, 08:38 AM   #6 (permalink)
Wahahaha~!
 
Faun's Avatar
 
Join Date: Dec 2006
Location: Pune/there
Posts: 7,676
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

^^guess not
__________________
Blog | Flickr | Battlelog
Spoiler:
Asus Z68 V-Pro|i5 2500k|TRUE Black|Ripjaws X|U2311H|N560GTX|D7000|XONAR STX|RE272|RE0|CC51|XE200PRO Walnut| TD II V2| Ultraphile|N5800

Mono
Faun is offline  
Old 10-07-2008, 05:33 PM   #7 (permalink)
Google Bot
 
Pathik's Avatar
 
Join Date: Aug 2005
Posts: 9,772
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

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

PS: Makes me feel like a genius coder.
__________________
My new blog: www.pathikshah.com
Pathik is offline  
Old 10-07-2008, 05:36 PM   #8 (permalink)
The Smaller Bang
 
MetalheadGautham's Avatar
 
Join Date: Sep 2007
Location: Gautham City
Posts: 7,490
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

Quote:
Originally Posted by Pathik View Post
PS: Makes me feel like a genius coder.

another homework obviously.
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
MetalheadGautham is online now  
Old 10-07-2008, 06:21 PM   #9 (permalink)
Davislav Ivanuiz!!!
 
Kl@w-24's Avatar
 
Join Date: Apr 2004
Location: Pune
Posts: 1,396
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

Maybe we should create a separate thread: "Post all your homework questions here"
__________________
I was here when the forum's swear filter kept bleeping out the word 'FUNK'. :crazy::censored::eeksign:

www.abhi247.com | The Photohblog A Little Lunacy! [v3]

Flickr!
Kl@w-24 is online now  
Old 10-07-2008, 07:07 PM   #10 (permalink)
GaurishSharma.com
 
gary4gar's Avatar
 
Join Date: May 2005
Location: Jaipur
Posts: 4,116
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

Quote:
Originally Posted by abh1shek View Post
Maybe we should create a separate thread: "Post all your homework questions here"
Only if you pay me for it
gary4gar is offline  
Old 10-07-2008, 07:28 PM   #11 (permalink)
MeSmEriZeR
 
Join Date: Apr 2008
Posts: 22
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

a=a^b;
b=a^b;
a=a^b;
__________________
Loading. . .
[███████████] 99%


///Everything which is done in this world is done in
hope///....
coolbuddy is offline  
Old 10-07-2008, 07:41 PM   #12 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,923
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

Quote:
Originally Posted by coolbuddy View Post
a=a^b;
b=a^b;
a=a^b;
won't "+" or "-" operators suffice ?? I think they are less expensive than "^" ...
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Old 10-07-2008, 08:04 PM   #13 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

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.
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 10-07-2008, 08:08 PM   #14 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,923
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

Quote:
Originally Posted by QwertyManiac View Post
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...
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Old 10-07-2008, 10:55 PM   #15 (permalink)
GaurishSharma.com
 
gary4gar's Avatar
 
Join Date: May 2005
Location: Jaipur
Posts: 4,116
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

Quote:
Originally Posted by QwertyManiac View Post
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"
gary4gar is offline  
Old 11-07-2008, 06:55 AM   #16 (permalink)
In The Zone
 
cooldip10's Avatar
 
Join Date: Mar 2005
Location: New Delhi
Posts: 493
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

a thread named "HOMEWORK HELP" must started

This will save space + other's problems can be reviewed without having to use the search engine
__________________
Everything is Possible
cooldip10 is offline  
Old 23-07-2008, 09:22 PM   #17 (permalink)
In The Zone
 
jal_desai's Avatar
 
Join Date: May 2006
Posts: 426
Default Re: i gt problem in C Program again !!! HELP ME PLS !!!

dont u think the question deserved no more than 2 posts.. (this applies to me also for posting this useless post)
__________________
TechExplorer.in
jal_desai is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Halo ladies and gentleman , i gt problem with this C program can help me ? ImBeck Programming 17 11-07-2008 07:28 PM
Problem encryption program in c++ Shikher_neo Programming 11 21-05-2008 02:14 PM
java smiley program problem ratedrsuperstar Programming 1 14-05-2008 09:53 AM
END PROGRAM PROBLEM kumarn_2004 QnA (read only) 2 11-12-2005 04:54 PM

 
Latest Threads
- by Sujeet
- by clmlbx
- by Sujeet
- by icebags

Advertisement




All times are GMT +5.5. The time now is 11:06 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2