as the title suggest i like to swap two numbers but the thing is that i should not use 3rd variable that is doing the whole stuff only with 2 variables so plz any body help me out

Googling will get you the answer you are seeking, but then after you know it, don't ever use it for programming today or in the future -- use a temporary variable. Solving yesterday's problems today is useful to understand the techniques, but the solution may no longer be applicable to current systems.

By the way, "XOR swap" might be a good phrase for your search.

Swapping two variables is an easy stuff if you are using temporary variable

void swap(int& a,int& b)
{
int temp=a;
a=b;
b=temp;
}
//in C++ template
template<typename _Type>
void swap(_Type& t, _Type& t2)
{
_Type temp=t;
t=t2;
t2=temp;
}

using only the two variables requires a little maths.
check that out it might work for ints.

void swap(int& a,int& b)
{
a=a+b;
b=a-b;
a=a-b;
}

Hope you got the basic idea........... try it out.....
The XOR algorithm is another choice and probably good one ...........and its simple check that out urself. remember (A ^ B) ^ B=A :)

using only the two variables requires a little maths.
check that out it might work for ints.

void swap(int& a,int& b)
{
a=a+b;
b=a-b;
a=a-b;
}

Hope you got the basic idea........... try it out.....
The XOR algorithm is another choice and probably good one ...........and its simple check that out urself. remember (A ^ B) ^ B=A :)

The more important part is knowing when the addition and subtraction fails for integers, and how the XOR swap may fail, and how to correctly code the XOR swap. And also why this doesn't work for some other variable types.

But as I said, after you've learned these techniques, remember never[*] to use them.

The more important part is knowing when the addition and subtraction fails for integers, and how the XOR swap may fail, and how to correctly code the XOR swap. And also why this doesn't work for some other variable types.

But as I said, after you've learned these techniques, remember never[*] to use them.

#include <stdio.h>
int swap ( int *a, int *b ) {
*a ^= *b;
*b ^= *a;
*a ^= *b;
}
int main(void)
{
int a = 2, b = 3;
printf( "%d %d\n", a, b );
swap( &a, &b );
printf( "%d %d\n", a, b );
swap( &a, &a ); /* swap with itself */
printf( "%d %d\n", a, b );
return 0;
}

What do you get with the final line of output?
Is it what you expected?

INGGRIS
How to connect device scanner with visual basic, its analogy I made button scan in vb and typing button scan in press scanner live and walk .. how? Help ...

For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
MsgBox(subCtrl.Text)
End If
If subCtrl.GetType Is ...

I am trying to write some code for project euler problem 10, in which you are required to find the sum of all the prime numbers less than 2 million. ...