C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






How to Swap two value with out using temp


Posted Date: 31 May 2008    Resource Type: Code Snippets    Category: C# Syntax

Posted By: anil momin       Member Level: Silver
Rating:     Points: 10



The following example shows how to Swap two value with out using temp

int a , b;
a = a + b;
b = a - b;
a = a - b;

Example:
a = 5 , b = 3
a = 5 + 3 = 8 // new value of a is 8
b = 8 - 3 = 5 // new value of b
a = 8 - 5 = 3 // now a = 3 and b = 5


This was a interview question..




Responses

Author: sunny khetarpal    01 Jun 2008Member Level: Bronze   Points : 2
@Anil

Thanks a lot for sharing such a gud solution


Author: Subrat Prusty    03 Jun 2008Member Level: Bronze   Points : 0
Very good.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to Compare time in string format
Previous Resource: How to determine whether the file you are trying to use is already in use or not
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

silicone halloween mask

Contact Us    Privacy Policy    Terms Of Use