what is the use of operator ^ in C ? and how it works?
Answers were Sorted based on User's Feedback
Answer / vinay sachan
exclusive OR ^ is a bitwise operator known as (left assoc).
expr1 ^ expr2
ex.
0x12 ^ 0x58
returns 0x4A (the set bits in the result are those that are set in either 0x12 or 0x58, but not set in both).
Is This Answer Correct ? | 7 Yes | 0 No |
Answer / rahul mathur
^ is a exclusive OR bitwise operator.
We can use this "^" operator for swaping two values without
using third variable and without using +, - operator as
shown below:
void xorSwap (int *x, int *y) {
if (x != y) {
*x ^= *y;
*y ^= *x;
*x ^= *y;
}
}
Is This Answer Correct ? | 4 Yes | 0 No |
what is the different between data structure and data type?
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
How will you write a code for accessing the length of an array without assigning it to another variable?
Write a program to compute the following 1!+2!+...n!
Write a C program to count the number of email on text
which will return integer? a) int*s ( ) b) ( int* ) s( ) c) int ( *s ) ( )
Tell me a C program to display the following Output? 1 1 1 1 1 2 2 2 2 3 3 3 4 4 5
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }
f() { int a=2; f1(a++); } f1(int c) { printf("%d", c); } c=?
What are local and global variables?
What is the difference between null pointer and wild pointer?
How. To pass the entrance test