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

Swap 2 variables without using 3rd variable


Code ResourceAuthor: deepu08  

Difficulty Level: Beginner

Published: 3rd Jun 2009   Read: 2608 times  

Filed in: C
Add Comment


 


This program swaps 2 varibles with out using of 3rd variable.

 


Sample Code
  1. #include<stdio.h>
  2. void main()
  3. {
  4.  int a,b;
  5.  printf("enter 2 numbers");
  6.  scanf("%d %d",&a,&b);
  7.  printf("nthe 2 numbers are %d %d",a,b);
  8.  a=a^b;
  9.  b=a^b;
  10.  a=a^b;
  11.  printf("n the 2 numbers are %d %d",a,b);
  12. }
Copyright GeekInterview.com


Next Article: Modified String Encryption


 

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)





Popular Coders

# Coder NameHits
1. kaivalya198914529
2. chandrikakr4698
3. meefriend4ever3433
4. sripri2845
5. deepu082609
6. Jimmy Zorald2485
7. Rajani1556
8. norman1400
9. reliable1020

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