answersLogoWhite

0

//lets assume

a = 10;

b = 20;

a = a^b;

b = a^b;

a = a^b;

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

How do you swap two numbers with bitwise operator in c plus plus?

// Note: ^ is the XOR operator a = a ^ b b = b ^ a a = a ^ b


How do you write a javascript to swap two numbers without using third one?

By using the algorithm of bitwise EORing (Exclusive ORing) the numbers together:If the two numbers are X and Y, then to swap them:X = X EOR YY = Y EOR XX =X EOR Ywill swap them.With knowledge of that algorithm, one then uses the syntax of Javascript to implement it.


Obtain algorithm that corresponds a program for the interchange of two numerical variable values?

In general, to swap two variables A and B with each other, you need a third variable T of the same type. You then perform the sequence T = A, A = B, and B = T. For the special case where A and B are binary types, you can swap them without a temporary variable using a bit-wise exclusive or operator. Using C/C++ syntax, you would use the sequence A ^= B, B ^= A, and A ^= B. For this to succeed, the exclusive or operator (^) must be bitwise. Actually, it is also possible to swap any two arbitrarily typed variables, such as float or object, so long as you can properly do the bitwise exclusive or operation, perhaps by doing typcasts or by playing games with pointers - although any of that is potentially dangerous and not always portable.


How do you swap two variables using bitwise operators?

a := a XOR b b := a XOR b a := a XOR b it works, but never use it in real programs do you know why its not used in real program??


What is program in c to swap entered two numbers without using third variable?

The required c program is given below /*Swapping(interchange) the two entered numbers*/ #include<stdio.h> main() { /*Without using third variable*/ int a,b,t; printf("Enter a:"); scanf("%d",&a); printf("Enter b:"); scanf("%d",&b); a=a+b; b=a-b; a=a-b; printf("\n After swapping without using third variable"); printf("\na=%d\nb=%d",a,b); }


What are the conditions to swap in c plus plus without temporary?

You can swap two integers without temporary storage by bitwise exclusive-or'ing them in a specific sequence...a ^= b;b ^= a;a ^= b;


Write a program to swap two numbers using function?

swap (int *a, int *b) { *a ^= *b; *b ^= *a; *a ^= *b; }


Swap two numbers using call by value and call by reference?

You cannot swap two numbers using call by value, because the called function does not have access to the original copy of the numbers.Swap with call by reference... This routine uses exclusive or swap without temporary variable.void swap (int *a, int *b) {*a ^= *b;*b ^= *a;*a ^= *b;return;}


How do you Nibble swap using bitwise operators?

If i is an unsigned char (1 byte unsigned integer) then: i (i << 4) | (i >> 4); If you know how to write inline assembly on your compiler (it differs between compilers), then rotating the byte is much more straightforward way to swap nibbles. In Intel assembly, it would look like: ror i, 4 So in Microsoft compilers it would look like: __asm { ror i,4 }


Swapping of number with using third variable?

To swap two numbers N1 and N2, using a third variable T... T = N1; N1 = N2; N2 = T;


Can you win in Uno by using a Swap Hands card?

No, you cannot win in Uno by using a Swap Hands card.


C program to swapping two numbers using call by value method?

You have to pass the address of the variables.void swap (int *pa, int *pb){...}