Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples C
 

Swaping two variables without using 3rd variable


Code ResourceAuthor: meefriend4ever  

Difficulty Level:

Published: 11th Sep 2007   Read: 3412 times  

Filed in: C
Add Comment


 


It is a program written by using 'C' language, The objective of this program is to swap two variables without using 3rd Variable.

 


Sample Code
  1.  
  2. printf("any 2 numbers");  
  3. scanf("%d,%d",&a,&b);
  4.  a=a^b;
  5.  b=a^b;
  6.  a=a^b;
  7.   printf("after swaping");
  8.   printf("%4d,%5d",a,b);
  9. }
  10.  
Copyright GeekInterview.com


Next Article: C Program to get Marks Card Details


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





Comments

proper one but the title should have been "swapping two integers(or characters) without using a temp vbl". This method cant be used with floating point numbers.
Comment posted by: jagatsastry on 2007-10-22T02:05:36

Popular Coders

# Coder NameHits
1. kaivalya198914472
2. chandrikakr4684
3. meefriend4ever3413
4. sripri2820
5. deepu082557
6. Jimmy Zorald2471
7. Rajani1543
8. norman1391
9. reliable1002

Active Coders

# Coder NameCodes
1. kaivalya19894
2. sripri1
3. Jimmy Zorald1
4. norman1
5. Rajani1
6. meefriend4ever1
7. chandrikakr1
8. reliable1
9. deepu081

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape