Code.GeekInterview.com
 
Code Samples C
 

Swaping two variables without using 3rd variable


Code ResourceAuthor: meefriend4ever  

Difficulty Level:

Published: 11th Sep 2007   Read: 7823 times  

Filed in: C
Add Comment


 

 

Sponsored Links


 

 

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 Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



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
Nice codes! An interesting platform for novice prgmmrs!!
Comment posted by: Dhanraj on 2011-07-08T13:51:12

Popular Coders

# Coder NameHits
1. kaivalya198932303
2. mano.mithun19243
3. deepu0817244
4. meefriend4ever7824
5. chandrikakr7815
6. shashivaishnav6687
7. sadasivathavamani6562
8. venkatakrishnansvpr6437
9. Jimmy Zorald6275
10. sripri5431

Active Coders

Refined Tags