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 |
How does selection sort work in c?
how to get starting address of a running C program
What is static and volatile in c?
What are the disadvantages of a shell structure?
Why n++ execute faster than n+1 ?
If the size of int data type is two bytes, what is the range of signed int data type?
#include<stdio.h> void main() { int a [5]; for (i=0; i<=4; i++) printf(ā%dā ,a[i]); }
When should you use a type cast?
What is volatile variable how do you declare it?
i am using gsm modem ! I USE CMGL COMMAND TO DISPLAY THE LIST OF MESSAGES ! I WANT TO READ EACH MESSAGE ONE BY ONE AND GET EACH MESSAGE INDEX USING C PROGRAM ! THE RESPONSE OF THE MODULE AFTER AT+CMGL IS ---CMGL: 1,"REC READ","+85291234567",,"07/05/01,08:00:15+32",145,37 It is easy to list SMS text messages.---- I WANT THE PROGRAM TO GET THE NUMBER "37"{MESSAGE LENGTH} AS WELL AS "1"(MESSAGE INDEX NUMBER" PLEASE HELP
What is the scope of an external variable in c?
What is data type long in c?