Hi Guest

MobileUser

1 HomePage 1 Jobs 1 WalkIn 1Articles  

Cat Exam

 :) Latest Topic
AJAX
VB.NET
SQL Query
UDDI
CLASS
JavaScript Questions
SharePoint Interview
SilverLight
WCF
general knowledge
 ASP.NET
 :) Hot Jobs
 
 :) Latest Articles


  

 
DogFood


Swap two int with temp variable and without temp variable
Question Posted on 01 Sep 2011

Home >> DotNet >> C# >> Swap two int with temp variable and without temp variable




Below source code will help you to swap values between two integer with help of temp variable and without temp variable
//define two variable
int i=2;
int j=6;

//with temp varible
int temp //as a temp varible
//swapping
int temp=i; //swap first variable to temp variable
int i=j; //swap value of second variable to first
j=temp //swap temp to second varible

//without temp varible
i=i+j; //add both number
j=i-j; //subtract second from first
i=i-j; //subtract second from first
0
0



 
 Input Your Comments Or suggestions(If Any)
 Name
 Email(optional)
 Comments


Other Important Questions
Simplest definition of partial classes and its rules?
Definition of Tuple class with some examples?
Define Race Condition in cSharp?
C#.Net Reserve Words
can we inherit private class level variables in c#






 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |